sensu-plugins-influxdb 1.1.0 → 1.2.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: 9274a7f429a5773b2b87785eb228d28732f870ba
4
- data.tar.gz: 181b6d9c4d45098cfe3a9d5d2ac479b69da97b09
3
+ metadata.gz: b2755c6881b5d17f0b2822ba142c16cc17f66814
4
+ data.tar.gz: c83c9e82c43df31971c5563d931d39da5bdb963f
5
5
  SHA512:
6
- metadata.gz: 9e2825358b70d0459f0a51362dce642f3869135fb720a353b7d7f83c65ff6cfb1b96928c45f3eee13576b596207e9a0c0b5d70da16a6714dbc91ab8480fad6bc
7
- data.tar.gz: 615ebd06c4d6ee7365689df7f16e72777af450e2dd021ea9eae4227a7ce840c02478b54837bb173a541acafafad711b3d610f5c0b0a70396bedf53bd9b53488c
6
+ metadata.gz: 79601be694e72ef79fa0502fce855c934aa1d513f965f6e1bbfb5959a857b97688478d4818d464672672dc31293a00bbf4ed2b3bd86bd5cf95411ce94d6a39cb
7
+ data.tar.gz: 7b44ccc30a4a39f27fe52787fde63cfafe8dee901d79c1bb5d0c9678b4f21b2c8530636b3c3b960e253f552c84ac00cd077f0d017ac9bb1b45ff1b0eae4a074e
data/CHANGELOG.md CHANGED
@@ -4,10 +4,12 @@ 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
+ ## [1.2.0] - 2017-05-15
8
+ - Added "mode" into check-influxdb-query check to allow multiple values in a query
7
9
 
8
10
  ## [1.1.0] - 2016-12-01
9
11
  ### Added
10
- - Added tags support for mutator-influxdb-line-protocol.rb
12
+ - Added tags support for mutator-influxdb-line-protocol.rb
11
13
  - Added retry support for check-influxdb-query.rb - The InfluxDB gem by default retries indefinitely and will cause the query to hang. A retry of 12 will retry for approx 37 seconds.
12
14
 
13
15
  ### Changed
@@ -66,7 +68,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
66
68
  ### Added
67
69
  - initial release
68
70
 
69
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-influxdb/compare/1.1.0...HEAD
71
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-influxdb/compare/1.2.0...HEAD
72
+ [1.2.0]: https://github.com/sensu-plugins/sensu-plugins-influxdb/compare/1.1.0...1.2.0
70
73
  [1.1.0]: https://github.com/sensu-plugins/sensu-plugins-influxdb/compare/1.0.0...1.1.0
71
74
  [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-influxdb/compare/0.0.7...1.0.0
72
75
  [0.0.7]: https://github.com/sensu-plugins/sensu-plugins-influxdb/compare/0.0.6...0.0.7
data/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
  * bin/mutator-influxdb-line-protocol.rb
16
16
 
17
17
  ## Usage - metrics-influxdb.rb
18
- Add the following to `/etc/sensu/conf.d/influx.conf` "plugin expects `influxdb` to be a top level node in the json
18
+ Add the following to `/etc/sensu/conf.d/influx.json` "plugin expects `influxdb` to be a top level node in the json
19
19
  **metrics-influxdb**
20
20
  ```
21
21
  {
@@ -43,7 +43,7 @@ Add the following to `/etc/sensu/conf.d/influx.conf` "plugin expects `influxdb`
43
43
  }
44
44
  }
45
45
  ```
46
- Then add the following to your `/ect/sensu/conf.d/handlers.conf`:
46
+ Then add the following to your `/etc/sensu/conf.d/handlers.json`:
47
47
  ```
48
48
  {
49
49
  "handlers": {
@@ -60,7 +60,7 @@ Setting "status" to true will store the metric using the status as the value and
60
60
  ## Usage - mutator-influxdb-line-protocol.rb
61
61
  Add the mutator-influxdb-line-protocol.rb file into /etc/sensu/extensions/
62
62
 
63
- Then add the following to your `/ect/sensu/conf.d/handlers.conf`:
63
+ Then add the following to your `/etc/sensu/conf.d/handlers.json`:
64
64
  ```
65
65
  {
66
66
  "handlers": {
@@ -70,7 +70,7 @@ Then add the following to your `/ect/sensu/conf.d/handlers.conf`:
70
70
  "host": "localhost",
71
71
  "port": 8090
72
72
  },
73
- "mutator": "influxdb_line_protocol",
73
+ "mutator": "influxdb_line_protocol"
74
74
  }
75
75
  }
76
76
  }
@@ -94,7 +94,7 @@ To ship additional tags to your metrics via mutator-influxdb-line-protocol.rb (o
94
94
  "type": "metric",
95
95
  "standalone": false,
96
96
  "tags": {
97
- "group": "operations",
97
+ "group": "operations"
98
98
  }
99
99
  }
100
100
  }
@@ -110,6 +110,12 @@ class CheckInfluxdbQuery < Sensu::Plugin::Check::CLI
110
110
  default: nil,
111
111
  description: 'Alias of query (e.g. if query and output gets too long)'
112
112
 
113
+ option :mode,
114
+ short: '-m MODE',
115
+ long: '--mode MODE',
116
+ default: 'first',
117
+ description: 'How the results are being checked (one of "first", "last", "max", "min", "avg") when the query returns more than one value'
118
+
113
119
  option :jsonpath,
114
120
  short: '-j JSONPATH',
115
121
  long: '--jsonpath JSONPATH',
@@ -179,19 +185,45 @@ class CheckInfluxdbQuery < Sensu::Plugin::Check::CLI
179
185
 
180
186
  if config[:jsonpath]
181
187
  json_path = JsonPath.new(config[:jsonpath])
182
- value = json_path.on(value).first || 0
183
-
184
188
  calc = Dentaku::Calculator.new
185
- if config[:critical] && calc.evaluate(config[:critical], value: value)
186
- critical "Value '#{value}' matched '#{config[:critical]}' for query '#{query_name}'"
187
- elsif config[:warning] && calc.evaluate(config[:warning], value: value)
188
- warning "Value '#{value}' matched '#{config[:warning]}' for query '#{query_name}'"
189
+ if config[:mode] == 'any' && json_path.on(value).length >= 1
190
+ json_path.on(value).each do |hashval|
191
+ if config[:critical] && calc.evaluate(config[:critical], value: hashval)
192
+ critical "Value '#{value}' matched '#{config[:critical]}' for query '#{query_name}'"
193
+ elsif config[:warning] && calc.evaluate(config[:warning], value: hashval)
194
+ warning "Value '#{value}' matched '#{config[:warning]}' for query '#{query_name}'"
195
+ end
196
+ end
197
+ ok 'All values OK!'
189
198
  else
190
- ok "Value '#{value}' ok for query '#{query_name}'"
199
+ value = get_single_value(json_path, value)
200
+ if config[:critical] && calc.evaluate(config[:critical], value: value)
201
+ critical "Value '#{value}' matched '#{config[:critical]}' for query '#{query_name}'"
202
+ elsif config[:warning] && calc.evaluate(config[:warning], value: value)
203
+ warning "Value '#{value}' matched '#{config[:warning]}' for query '#{query_name}'"
204
+ else
205
+ ok "Value '#{value}' ok for query '#{query_name}'"
206
+ end
191
207
  end
192
208
  else
193
209
  puts 'Debug output. Use -j to check value...'
194
210
  puts JSON.pretty_generate(value)
195
211
  end
196
212
  end
213
+
214
+ def get_single_value(jpath, value)
215
+ return 0 if jpath.on(value).empty?
216
+ case config[:mode]
217
+ when 'last'
218
+ jpath.on(value).last
219
+ when 'min'
220
+ jpath.on(value).min
221
+ when 'max'
222
+ jpath.on(value).max
223
+ when 'avg', 'average'
224
+ jpath.on(value).inject(:+).to_f / jpath.on(value).length
225
+ else
226
+ jpath.on(value).first
227
+ end
228
+ end
197
229
  end
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsInfluxdb
2
2
  module Version
3
3
  MAJOR = 1
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-influxdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.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: 2016-12-02 00:00:00.000000000 Z
11
+ date: 2017-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dentaku