bin/check-influxdb.rb in sensu-plugins-influxdb-0.0.3 vs bin/check-influxdb.rb in sensu-plugins-influxdb-0.0.4

- old
+ new

@@ -55,11 +55,11 @@ long: '--ssl', boolean: true, default: false option :timeout, - description: 'Seconds to wait for the connection to open or read (default: 1.0s)', + description: 'Seconds to wait for the connection to open or read (default: 1.0s)', short: '-t SECONDS', long: '--timeout SECONDS', proc: proc(&:to_f), default: 1.0 @@ -67,14 +67,15 @@ http = Net::HTTP.new(config[:host], config[:port]) http.open_timeout = config[:timeout] http.read_timeout = config[:timeout] http.use_ssl = config[:ssl] http.start do - status = JSON.parse(http.get('/ping').body) - if status == { 'status' => 'ok' } - ok status.to_s + response = http.get('/ping') + status_line = "#{response.code} #{response.message}" + if response.is_a?(Net::HTTPSuccess) + ok status_line else - critical status.to_s + critical status_line end end rescue => e critical e.to_s end