bin/check-http-json.rb in sensu-plugins-http-2.8.4 vs bin/check-http-json.rb in sensu-plugins-http-2.9.0

- old
+ new

@@ -26,10 +26,13 @@ # # Check that will verify http status, JSON validity, and that page.totalElements value is # greater than 10 # ./check-http-json.rb -u http://my.site.com/metric.json --key page.totalElements --value-greater-than 10 # +# Check that will POST json +# ./check-http-json.rb -u http://my.site.com/metric.json -m POST --header 'Content-type: application/json' --post-body '{"serverId": "myserver"}' +# # NOTES: # Based on Check HTTP by Sonian Inc. # # LICENSE: # Copyright 2013 Matt Revell <nightowlmatt@gmail.com> @@ -51,10 +54,11 @@ option :path, short: '-p PATH' option :query, short: '-q QUERY' option :port, short: '-P PORT', proc: proc(&:to_i) option :method, short: '-m GET|POST' option :postbody, short: '-b /file/with/post/body' + option :post_body, long: '--post-body VALUE' option :header, short: '-H HEADER', long: '--header HEADER' option :ssl, short: '-s', boolean: true, default: false option :insecure, short: '-k', boolean: true, default: false option :user, short: '-U', long: '--username USER' option :password, short: '-a', long: '--password PASS' @@ -161,9 +165,12 @@ Net::HTTP::Get.new([config[:path], config[:query]].compact.join('?')) end if config[:postbody] post_body = IO.readlines(config[:postbody]) req.body = post_body.join + end + if config[:post_body] + req.body = config[:post_body] end unless config[:user].nil? && config[:password].nil? req.basic_auth config[:user], config[:password] end if config[:header]