bin/check-http.rb in sensu-plugins-http-2.4.0 vs bin/check-http.rb in sensu-plugins-http-2.5.0

- old
+ new

@@ -42,10 +42,11 @@ # Updated by Chris Armstrong 2013 to accept multiple headers # Released under the same terms as Sensu (the MIT license); see LICENSE # for details. # +require 'sensu-plugins-http' require 'sensu-plugin/check/cli' require 'net/http' require 'net/https' require 'digest' @@ -199,10 +200,27 @@ long: '--noproxy', boolean: true, description: 'Do not use proxy server even from environment http_proxy setting', default: false + option :aws_v4, + long: '--aws-v4', + boolean: true, + description: 'Sign http request with AWS v4 signature', + default: false + + option :aws_v4_region, + long: '--aws-v4-region REGION', + description: 'Region to use for AWS v4 signing. Defaults to AWS_REGION or AWS_DEFAULT_REGION' + + option :aws_v4_service, + long: '--aws-v4-service SERVICE', + description: 'Service name to use when building the v4 signature', + default: 'execute-api' + + include SensuPluginsHttp::AwsV4 + def run if config[:url] uri = URI.parse(config[:url]) config[:host] = uri.host config[:port] = uri.port @@ -288,9 +306,11 @@ h, v = header.split(':', 2) req[h.strip] = v.strip end end req.body = config[:body] if config[:body] + + req = apply_v4_signature(http, req, config) if config[:aws_v4] res = http.request(req) body = if config[:whole_response] "\n" + res.body