bin/check-http-json.rb in sensu-plugins-http-5.1.0 vs bin/check-http-json.rb in sensu-plugins-http-5.1.1

- old
+ new

@@ -139,13 +139,13 @@ end end end def json_valid?(str) - JSON.parse(str) + ::JSON.parse(str) return true - rescue JSON::ParserError + rescue ::JSON::ParserError return false end def acquire_resource http = Net::HTTP.new(config[:host], config[:port]) @@ -192,11 +192,11 @@ critical res.code end critical 'invalid JSON from request' unless json_valid?(res.body) ok 'valid JSON returned' if config[:key].nil? && config[:value].nil? - json = JSON.parse(res.body) + json = ::JSON.parse(res.body) begin leaf = deep_value(json, config[:key]) raise "could not find key: #{config[:key]}" if leaf.nil? @@ -216,10 +216,10 @@ end ok message rescue StandardError => e if config[:dump_json] - json_response = config[:pretty] ? JSON.pretty_generate(json) : json + json_response = config[:pretty] ? ::JSON.pretty_generate(json) : json message = "key check failed: #{e}. Response: #{json_response}" else message = "key check failed: #{e}" end critical message