sensu-plugins-influxdb 1.1.0 → 1.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 +4 -4
- data/CHANGELOG.md +5 -2
- data/README.md +5 -5
- data/bin/check-influxdb-query.rb +39 -7
- data/lib/sensu-plugins-influxdb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2755c6881b5d17f0b2822ba142c16cc17f66814
|
4
|
+
data.tar.gz: c83c9e82c43df31971c5563d931d39da5bdb963f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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 `/
|
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 `/
|
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
|
}
|
data/bin/check-influxdb-query.rb
CHANGED
@@ -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[:
|
186
|
-
|
187
|
-
|
188
|
-
|
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
|
-
|
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
|
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.
|
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:
|
11
|
+
date: 2017-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dentaku
|