null+****@clear*****
null+****@clear*****
2011年 11月 17日 (木) 19:24:48 JST
Kouhei Sutou 2011-11-17 10:24:48 +0000 (Thu, 17 Nov 2011) New Revision: 9830395791585c916c387b11b55cc4ad9ba0cd8e Log: [munin][throughput] handle error on HTTP. Modified files: data/munin/groonga_throughput Modified: data/munin/groonga_throughput (+13 -7) =================================================================== --- data/munin/groonga_throughput 2011-11-17 07:06:24 +0000 (30d8bd8) +++ data/munin/groonga_throughput 2011-11-17 10:24:48 +0000 (5efb8ad) @@ -39,13 +39,19 @@ end def run(command, *args) if @protocol == "http" require "net/http" - response = Net::HTTP.start(@host, @port) do |http| - http.get("/d/status.json") - end - if response.is_a?(Net::HTTPSuccess) - parse(true, response.body) - else - parse(false, "#{response.code}: #{response.body}") + begin + response = Net::HTTP.start(@host, @port) do |http| + http.get("/d/status.json") + end + if response.is_a?(Net::HTTPSuccess) + parse(true, response.body) + else + parse(false, "#{response.code}: #{response.body}") + end + rescue Exception + message = "#{$!.class}: #{$!.message}\n" + message << $@.join("\n") + parse(false, message) end else groonga = "#{@groonga} -p #{@port} -c #{@host}"