sensu-plugins-sensu 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2a48f5448ae128816efb0bcc6435d5cae5670a7
4
- data.tar.gz: f31f95bbf5a84e793ea767e23787f408ae241a90
3
+ metadata.gz: 2870929cd3cd4f899088cb6ec55104e76807d063
4
+ data.tar.gz: 3e346d7facc6bf08e84d1993a40e1d4e1345faad
5
5
  SHA512:
6
- metadata.gz: 975c86c23b6a520a7589520577fb69cc174fc790d80f1fe18d84054f52ecda966c6be7ee02d7cbb67d57695cb70f1a06e55aea7255226f81e9bdc2e1f9730704
7
- data.tar.gz: 9eb37672b302b8ec703f9074effe22c6f5b508708acd624ee3953c56b01d713e05bda461d2932e460835f88916918416fff3dc4b0fe85634eef6c01a675396d7
6
+ metadata.gz: a90af312010e2d9ba78c824d54c64f3fd50918d1d647a1601cd221b31b2cd92e6a5448271df7ab57503048316e1ff1cd5365a1fb8555d93abf5aca56b2ec649e
7
+ data.tar.gz: 40800095ddbdcd9559a2b8411094a841f4295884bec1ea137ec6bde7d4ce77f7753d7511c1f297f475448c50b9c9653024bbe11d899447b40e36af6306f7a4e5
data/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [2.0.0] - 2017-08-20
9
+ ### Breaking Changes
10
+ - check-aggregates.rb: Changed the default behaviour to alert with the severity of the aggregated checks.
11
+
12
+ ### Added
13
+ - check-aggregates.rb: Added new flag to ignore severities. If --ignore-severity is supplied all non-ok will count for critical, critical_count, warning and warning_count option.
14
+
15
+ ### Fixed
16
+ - handler-sensu-deregister.rb: Fix undefined variable in case of API error.
17
+
8
18
  ## [1.1.1] - 2017-08-01
9
19
  ### Added
10
20
  - Ruby 2.4 testing (@Evesy)
@@ -55,6 +65,7 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
55
65
  - initial release
56
66
 
57
67
  [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/1.1.1...HEAD
68
+ [2.0.0]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/1.1.1...2.0.0
58
69
  [1.1.1]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/1.1.0...1.1.1
59
70
  [1.1.0]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/1.0.0...1.1.0
60
71
  [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/0.1.0...1.0.0
@@ -88,23 +88,23 @@ class CheckAggregate < Sensu::Plugin::Check::CLI
88
88
  option :warning,
89
89
  short: '-W PERCENT',
90
90
  long: '--warning PERCENT',
91
- description: 'PERCENT non-ok before warning',
91
+ description: 'PERCENT warning before warning (can be change with --ignore-severity)',
92
92
  proc: proc(&:to_i)
93
93
 
94
94
  option :warning_count,
95
95
  long: '--warning_count INTEGER',
96
- description: 'number of nodes in warning before warning',
96
+ description: 'number of nodes in warning before warning (can be change with --ignore-severity)',
97
97
  proc: proc(&:to_i)
98
98
 
99
99
  option :critical,
100
100
  short: '-C PERCENT',
101
101
  long: '--critical PERCENT',
102
- description: 'PERCENT non-ok before critical',
102
+ description: 'PERCENT critical before critical (can be change with --ignore-severity)',
103
103
  proc: proc(&:to_i)
104
104
 
105
105
  option :critical_count,
106
106
  long: '--critical_count INTEGER',
107
- description: 'number of node in critical before critical',
107
+ description: 'number of node in critical before critical (can be change with --ignore-severity)',
108
108
  proc: proc(&:to_i)
109
109
 
110
110
  option :pattern,
@@ -124,6 +124,12 @@ class CheckAggregate < Sensu::Plugin::Check::CLI
124
124
  long: '--message MESSAGE',
125
125
  description: 'A custom error MESSAGE'
126
126
 
127
+ option :ignore_severity,
128
+ long: '--ignore-severity',
129
+ description: 'Ignore severities, all non-ok will count for critical, critical_count, warning and warning_count option',
130
+ boolean: true,
131
+ default: false
132
+
127
133
  def api_request(resource)
128
134
  verify_mode = OpenSSL::SSL::VERIFY_PEER
129
135
  verify_mode = OpenSSL::SSL::VERIFY_NONE if config[:insecure]
@@ -209,21 +215,25 @@ class CheckAggregate < Sensu::Plugin::Check::CLI
209
215
  end
210
216
 
211
217
  def compare_thresholds(aggregate)
212
- percent_non_zero = (100 - (aggregate[:ok].to_f / aggregate[:total].to_f) * 100).to_i
213
- message = ''
214
- if aggregate[:outputs]
215
- aggregate[:outputs].each do |output, count|
216
- message << "\n" + output.to_s if count == 1
218
+ message = config[:message] || 'Number of non-zero results exceeds threshold'
219
+ message += ' (%d%% %s)'
220
+ message += "\n" + aggregate[:outputs] if aggregate[:outputs]
221
+
222
+ if config[:ignore_severity]
223
+ percent_non_zero = (100 - (aggregate[:ok].to_f / aggregate[:total].to_f) * 100).to_i
224
+ if config[:critical] && percent_non_zero >= config[:critical]
225
+ critical format(message, percent_non_zero, 'non-zero')
226
+ elsif config[:warning] && percent_non_zero >= config[:warning]
227
+ warning format(message, percent_non_zero, 'non-zero')
217
228
  end
218
229
  else
219
- message = config[:message] || 'Number of non-zero results exceeds threshold'
220
- message += " (#{percent_non_zero}% non-zero)"
221
- end
222
-
223
- if config[:critical] && percent_non_zero >= config[:critical]
224
- critical message
225
- elsif config[:warning] && percent_non_zero >= config[:warning]
226
- warning message
230
+ percent_warning = (aggregate[:warning].to_f / aggregate[:total].to_f * 100).to_i
231
+ percent_critical = (aggregate[:critical].to_f / aggregate[:total].to_f * 100).to_i
232
+ if config[:critical] && percent_critical >= config[:critical]
233
+ critical format(message, percent_critical, 'critical')
234
+ elsif config[:warning] && percent_warning >= config[:warning]
235
+ warning format(message, percent_warning, 'warning')
236
+ end
227
237
  end
228
238
  end
229
239
 
@@ -247,21 +257,26 @@ class CheckAggregate < Sensu::Plugin::Check::CLI
247
257
  end
248
258
 
249
259
  def compare_thresholds_count(aggregate)
250
- number_of_nodes_reporting_down = aggregate[:total].to_i - aggregate[:ok].to_i
251
- message = ''
252
- if aggregate[:outputs]
253
- aggregate[:outputs].each do |output, count|
254
- message << "\n" + output.to_s if count == 1
260
+ message = config[:message] || 'Number of nodes down exceeds threshold'
261
+ message += " (%s out of #{aggregate[:total]} nodes reporting %s)"
262
+ message += "\n" + aggregate[:outputs] if aggregate[:outputs]
263
+
264
+ if config[:ignore_severity]
265
+ number_of_nodes_reporting_down = aggregate[:total].to_i - aggregate[:ok].to_i
266
+ if config[:critical_count] && number_of_nodes_reporting_down >= config[:critical_count]
267
+ critical format(message, number_of_nodes_reporting_down, 'not ok')
268
+ elsif config[:warning_count] && number_of_nodes_reporting_down >= config[:warning_count]
269
+ warning format(message, number_of_nodes_reporting_down, 'not ok')
255
270
  end
256
271
  else
257
- message = config[:message] || 'Number of nodes down exceeds threshold'
258
- message += " (#{number_of_nodes_reporting_down} out of #{aggregate[:total]} nodes reporting not ok)"
259
- end
272
+ nodes_reporting_warning = aggregate[:warning].to_i
273
+ nodes_reporting_critical = aggregate[:critical].to_i
260
274
 
261
- if config[:critical_count] && number_of_nodes_reporting_down >= config[:critical_count]
262
- critical message
263
- elsif config[:warning_count] && number_of_nodes_reporting_down >= config[:warning_count]
264
- warning message
275
+ if config[:critical_count] && nodes_reporting_critical >= config[:critical_count]
276
+ critical format(message, nodes_reporting_critical, 'critical')
277
+ elsif config[:warning_count] && nodes_reporting_warning >= config[:warning_count]
278
+ warning format(message, nodes_reporting_warning, 'warning')
279
+ end
265
280
  end
266
281
  end
267
282
 
@@ -1,9 +1,9 @@
1
1
  module SensuPluginsSensu
2
2
  # This defines the version of the gem
3
3
  module Version
4
- MAJOR = 1
5
- MINOR = 1
6
- PATCH = 1
4
+ MAJOR = 2
5
+ MINOR = 0
6
+ PATCH = 0
7
7
 
8
8
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-sensu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 2.0.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-08-01 00:00:00.000000000 Z
11
+ date: 2017-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin