sensu-plugins-http 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/bin/check-http.rb +20 -0
- data/lib/sensu-plugins-http/aws-v4.rb +38 -0
- data/lib/sensu-plugins-http/version.rb +1 -1
- data/lib/sensu-plugins-http.rb +1 -0
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a45f782620f82677c15eebd6b7b47a78ec9f088
|
4
|
+
data.tar.gz: 7ebd595a2c7e394ff91c0f80f0309529ee9a736d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ba70ef7c3d652b2ad84988feab12f494c225c609d1d53b58ce2bd9aefc68389cfceb21d43ba36290d53c4b7dac3a021f3f0e2fbe9fd8854a0bbe8d0e206d5a3
|
7
|
+
data.tar.gz: ec9597333137cee04918cb0de68f7c865ca84df3d40ed33730afcb92d7c3cb15612713569fbc797379651f3c8203de7dbc1d750af6187534f740f2c0bdeda2c7
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,10 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [2.5.0] - 2017-07-06
|
9
|
+
### Added
|
10
|
+
- `check-http`: Added ability to sign requests with AWS V4 authentication (@ajmath)
|
11
|
+
|
8
12
|
## [2.4.0] - 2017-06-19
|
9
13
|
### Added
|
10
14
|
- Initial set of tests for `check-https-cert.rb` (@pgporada)
|
@@ -139,7 +143,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
139
143
|
### Added
|
140
144
|
- Initial release
|
141
145
|
|
142
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.
|
146
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.5.0...HEAD
|
147
|
+
[2.5.0]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.4.0...2.5.0
|
143
148
|
[2.4.0]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.3.0...2.4.0
|
144
149
|
[2.3.0]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.2.0...2.3.0
|
145
150
|
[2.2.0]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.1.0...2.2.0
|
data/bin/check-http.rb
CHANGED
@@ -44,6 +44,7 @@
|
|
44
44
|
# for details.
|
45
45
|
#
|
46
46
|
|
47
|
+
require 'sensu-plugins-http'
|
47
48
|
require 'sensu-plugin/check/cli'
|
48
49
|
require 'net/http'
|
49
50
|
require 'net/https'
|
@@ -201,6 +202,23 @@ class CheckHttp < Sensu::Plugin::Check::CLI
|
|
201
202
|
description: 'Do not use proxy server even from environment http_proxy setting',
|
202
203
|
default: false
|
203
204
|
|
205
|
+
option :aws_v4,
|
206
|
+
long: '--aws-v4',
|
207
|
+
boolean: true,
|
208
|
+
description: 'Sign http request with AWS v4 signature',
|
209
|
+
default: false
|
210
|
+
|
211
|
+
option :aws_v4_region,
|
212
|
+
long: '--aws-v4-region REGION',
|
213
|
+
description: 'Region to use for AWS v4 signing. Defaults to AWS_REGION or AWS_DEFAULT_REGION'
|
214
|
+
|
215
|
+
option :aws_v4_service,
|
216
|
+
long: '--aws-v4-service SERVICE',
|
217
|
+
description: 'Service name to use when building the v4 signature',
|
218
|
+
default: 'execute-api'
|
219
|
+
|
220
|
+
include SensuPluginsHttp::AwsV4
|
221
|
+
|
204
222
|
def run
|
205
223
|
if config[:url]
|
206
224
|
uri = URI.parse(config[:url])
|
@@ -291,6 +309,8 @@ class CheckHttp < Sensu::Plugin::Check::CLI
|
|
291
309
|
end
|
292
310
|
req.body = config[:body] if config[:body]
|
293
311
|
|
312
|
+
req = apply_v4_signature(http, req, config) if config[:aws_v4]
|
313
|
+
|
294
314
|
res = http.request(req)
|
295
315
|
|
296
316
|
body = if config[:whole_response]
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module SensuPluginsHttp
|
2
|
+
module AwsV4
|
3
|
+
# Returns a modified request object with AWS v4 signature headers
|
4
|
+
# and authentication options (if any)
|
5
|
+
#
|
6
|
+
# @param [Net::HTTP] http
|
7
|
+
# The http object used to execute the request. Used to build uri
|
8
|
+
# @param [Net::HTTPGenericRequest] req
|
9
|
+
# The http request. Used to populate headers, path, method, and body
|
10
|
+
# @param [Hash] options Details about how to configure the request
|
11
|
+
# @option options [String] :aws_v4_service
|
12
|
+
# AWS service to use in signature. Defaults to 'execute-api'
|
13
|
+
# @option options [String] :aws_v4_region
|
14
|
+
# AWS region to use in signature. Defaults to
|
15
|
+
# ENV['AWS_REGION'] or ENV['AWS_DEFAULT_REGION']
|
16
|
+
def apply_v4_signature(http, req, options = {})
|
17
|
+
require 'aws-sdk'
|
18
|
+
|
19
|
+
fake_seahorse = Struct.new(:endpoint, :body, :headers, :http_method)
|
20
|
+
headers = {}
|
21
|
+
req.each_name { |name| headers[name] = req[name] }
|
22
|
+
protocol = http.use_ssl? ? 'https' : 'http'
|
23
|
+
uri = URI.parse("#{protocol}://#{http.address}:#{http.port}#{req.path}")
|
24
|
+
fake_req = fake_seahorse.new(uri, req.body || '',
|
25
|
+
headers, req.method)
|
26
|
+
|
27
|
+
credentials = Aws::CredentialProviderChain.new.resolve
|
28
|
+
service = options[:aws_v4_service] || 'execute-api'
|
29
|
+
region = options[:aws_v4_region] || ENV['AWS_REGION'] || ENV['AWS_DEFAULT_REGION']
|
30
|
+
signer = Aws::Signers::V4.new(credentials, service, region)
|
31
|
+
|
32
|
+
signed_req = signer.sign(fake_req)
|
33
|
+
signed_req.headers.each { |key, value| req[key] = value }
|
34
|
+
|
35
|
+
req
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/sensu-plugins-http.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -241,15 +241,15 @@ description: |-
|
|
241
241
|
SSL expiry, and metrics via `curl`.
|
242
242
|
email: "<sensu-users@googlegroups.com>"
|
243
243
|
executables:
|
244
|
-
- check-http-json.rb
|
245
|
-
- check-http.rb
|
246
244
|
- metrics-http-json-deep.rb
|
247
|
-
- metrics-
|
248
|
-
- check-last-modified.rb
|
245
|
+
- metrics-curl.rb
|
249
246
|
- check-http-cors.rb
|
250
247
|
- check-https-cert.rb
|
248
|
+
- check-last-modified.rb
|
249
|
+
- check-http.rb
|
250
|
+
- check-http-json.rb
|
251
|
+
- metrics-http-json.rb
|
251
252
|
- check-head-redirect.rb
|
252
|
-
- metrics-curl.rb
|
253
253
|
extensions: []
|
254
254
|
extra_rdoc_files: []
|
255
255
|
files:
|
@@ -266,6 +266,7 @@ files:
|
|
266
266
|
- bin/metrics-http-json-deep.rb
|
267
267
|
- bin/metrics-http-json.rb
|
268
268
|
- lib/sensu-plugins-http.rb
|
269
|
+
- lib/sensu-plugins-http/aws-v4.rb
|
269
270
|
- lib/sensu-plugins-http/common.rb
|
270
271
|
- lib/sensu-plugins-http/version.rb
|
271
272
|
homepage: https://github.com/sensu-plugins/sensu-plugins-http
|
@@ -294,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
294
295
|
version: '0'
|
295
296
|
requirements: []
|
296
297
|
rubyforge_project:
|
297
|
-
rubygems_version: 2.
|
298
|
+
rubygems_version: 2.6.12
|
298
299
|
signing_key:
|
299
300
|
specification_version: 4
|
300
301
|
summary: Sensu plugins for various http monitors and metrics
|