sensu-plugins-http 2.1.0 → 2.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a80fe427bc654ad938c9ef9dd0aac9485778a35
4
- data.tar.gz: caf691caa222f28a009329a82a437dd44077d8e0
3
+ metadata.gz: 6e3afdef217237a86469b5b3c02d9fbea9174cca
4
+ data.tar.gz: 4af732af7c2f5d722d10f4a8cfff8a23d128c34c
5
5
  SHA512:
6
- metadata.gz: 67c642ac68ae94fa2e5a322ba53c02f5bc6989fac0dfbfc912ebb587729a193665366270a5437afb059b4728e26c1b06b4e5a98018b0bca0b110cc8c65192f84
7
- data.tar.gz: 09446024c1bfaeb932b4c79a72c46fffc6a11af39cb62b99e8f3d7167190c6f42623edab6ad98e2b042a3aee468cd01bc9192482dbbe59e7f887a8bf317f4be5
6
+ metadata.gz: 0e9d6e5ddf2b72eaf499cc355b536d4913f9e3b4fbb44227553c31c837875afc497b10de1013ebdfdebf398ead1a50e98bf59b5b9499921e73cac0f2688e613c
7
+ data.tar.gz: 21e5cacdb6206226f04e91027eecd5e0413a04ba1eb9225a83e3e108fcc3caf5d93bdd9d07f5e9daa9d9ffb01c594292e5ef94d561214d9f504e0106268801c4
@@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
6
  ## [Unreleased]
7
+ ## [2.2.0] - 2017-05-31
8
+ ### Added
9
+ - `check-http-json`: add --value-greater-than and --value-less-than options (@dave-handy)
10
+
7
11
  ## [2.1.0]
8
12
  ### Fixed
9
13
  - `check-http-json`: fix error when check fails and --whole-response is enabled (@ushis)
@@ -124,7 +128,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
124
128
  ### Added
125
129
  - Initial release
126
130
 
127
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.1.0...HEAD
131
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.2.0...HEAD
132
+ [2.2.0]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.1.0...2.2.0
128
133
  [2.1.0]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.0.2...2.1.0
129
134
  [2.0.2]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.0.1...2.0.2
130
135
  [2.0.1]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.0.0...2.0.1
@@ -5,7 +5,8 @@
5
5
  # DESCRIPTION:
6
6
  # Takes either a URL or a combination of host/path/query/port/ssl, and checks
7
7
  # for valid JSON output in the response. Can also optionally validate simple
8
- # string key/value pairs.
8
+ # string key/value pairs, and optionally check if a specified value is within
9
+ # bounds.
9
10
  #
10
11
  # OUTPUT:
11
12
  # plain text
@@ -18,7 +19,12 @@
18
19
  # gem: json
19
20
  #
20
21
  # USAGE:
21
- # #YELLOW
22
+ # Check that will verify http status and JSON validity
23
+ # ./check-http-json.rb -u http://my.site.com/health.json
24
+ #
25
+ # Check that will verify http status, JSON validity, and that page.totalElements value is
26
+ # greater than 10
27
+ # ./check-http-json.rb -u http://my.site.com/metric.json --key page.totalElements --value-greater-than 10
22
28
  #
23
29
  # NOTES:
24
30
  # Based on Check HTTP by Sonian Inc.
@@ -56,6 +62,8 @@ class CheckJson < Sensu::Plugin::Check::CLI
56
62
  option :timeout, short: '-t SECS', proc: proc(&:to_i), default: 15
57
63
  option :key, short: '-K KEY', long: '--key KEY'
58
64
  option :value, short: '-v VALUE', long: '--value VALUE'
65
+ option :valueGt, long: '--value-greater-than VALUE'
66
+ option :valueLt, long: '--value-less-than VALUE'
59
67
  option :whole_response, short: '-w', long: '--whole-response', boolean: true, default: false
60
68
 
61
69
  def run
@@ -176,9 +184,22 @@ class CheckJson < Sensu::Plugin::Check::CLI
176
184
  leaf = deep_value(json, config[:key])
177
185
 
178
186
  raise "could not find key: #{config[:key]}" if leaf.nil?
179
- raise "unexpected value for key: '#{config[:value]}' != '#{leaf}'" unless leaf.to_s == config[:value].to_s
180
187
 
181
- ok "key has expected value: '#{config[:key]}' = '#{config[:value]}'"
188
+ message = "key has expected value: '#{config[:key]}' "
189
+ if config[:value]
190
+ raise "unexpected value for key: '#{leaf}' != '#{config[:value]}'" unless leaf.to_s == config[:value].to_s
191
+ message += " equals '#{config[:value]}'"
192
+ end
193
+ if config[:valueGt]
194
+ raise "unexpected value for key: '#{leaf}' not > '#{config[:valueGt]}'" unless leaf.to_f > config[:valueGt].to_f
195
+ message += " greater than '#{config[:valueGt]}'"
196
+ end
197
+ if config[:valueLt]
198
+ raise "unexpected value for key: '#{leaf}' not < '#{config[:valueLt]}'" unless leaf.to_f < config[:valueLt].to_f
199
+ message += " less than '#{config[:valueLt]}'"
200
+ end
201
+
202
+ ok message
182
203
  rescue => e
183
204
  critical "key check failed: #{e}"
184
205
  end
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsHttp
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 1
4
+ MINOR = 2
5
5
  PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
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.1.0
4
+ version: 2.2.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-05-24 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin