bin/check-http-json.rb in sensu-plugins-http-5.1.1 vs bin/check-http-json.rb in sensu-plugins-http-6.0.0
- old
+ new
@@ -140,13 +140,13 @@
end
end
def json_valid?(str)
::JSON.parse(str)
- return true
+ true
rescue ::JSON::ParserError
- return false
+ false
end
def acquire_resource
http = Net::HTTP.new(config[:host], config[:port])
@@ -202,17 +202,20 @@
raise "could not find key: #{config[:key]}" if leaf.nil?
message = "key has expected value: '#{config[:key]}' "
if config[:value]
raise "unexpected value for key: '#{leaf}' != '#{config[:value]}'" unless leaf.to_s == config[:value].to_s
+
message += "equals '#{config[:value]}'"
end
if config[:valueGt]
raise "unexpected value for key: '#{leaf}' not > '#{config[:valueGt]}'" unless leaf.to_f > config[:valueGt].to_f
+
message += "greater than '#{config[:valueGt]}'"
end
if config[:valueLt]
raise "unexpected value for key: '#{leaf}' not < '#{config[:valueLt]}'" unless leaf.to_f < config[:valueLt].to_f
+
message += "less than '#{config[:valueLt]}'"
end
ok message
rescue StandardError => e