sensu-plugins-influxdb-q 0.0.5 → 0.0.6
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 -1
- data/bin/check-influxdb-q.rb +38 -24
- data/lib/sensu-plugins-influxdb-q/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: aa4effaf4b971f17d0624a2ad4283e1ca4648ae3
|
4
|
+
data.tar.gz: 47ae909be1bf11062607eb23f9abff7756731884
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fab571e87cc6f69abc25dc221de8f87d8da88a7e15ceb6a7e36764bae322e62a9ab966b85c71f10653844ef15b39ff7639adf826e7eaef63a04931ae3267f393
|
7
|
+
data.tar.gz: 4beb7592325166c1b051eb36d7f1b05af52753e1c04e4286818abce3428059bf319db6a372d29e9846fb7548a3af0319562f1493f9f244f35088257b6614c67e
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
3
3
|
|
4
4
|
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
5
|
|
6
|
-
##
|
6
|
+
## [0.0.6] - 2016-01-18
|
7
|
+
### Added
|
8
|
+
- Added query timeout option
|
7
9
|
|
8
10
|
## [0.0.5] - 2016-01-14
|
9
11
|
### Added
|
@@ -24,3 +26,5 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
24
26
|
## [0.0.1] - 2016-01-07
|
25
27
|
### Added
|
26
28
|
- Initial release
|
29
|
+
|
30
|
+
## Unreleased
|
data/bin/check-influxdb-q.rb
CHANGED
@@ -14,6 +14,7 @@ require 'sensu-plugin/check/cli'
|
|
14
14
|
require 'influxdb'
|
15
15
|
require 'jsonpath'
|
16
16
|
require 'dentaku'
|
17
|
+
require 'timeout'
|
17
18
|
|
18
19
|
class Hash
|
19
20
|
def symbolize_recursive
|
@@ -80,6 +81,12 @@ class CheckInfluxDbQ < Sensu::Plugin::Check::CLI
|
|
80
81
|
:default => false,
|
81
82
|
:boolean => true
|
82
83
|
|
84
|
+
option :timeout,
|
85
|
+
:description => "InfluxDB query timeout (default: 3)",
|
86
|
+
:long => "--timeout <SECONDS>",
|
87
|
+
:proc => proc { |i| i.to_i },
|
88
|
+
:default => 3
|
89
|
+
|
83
90
|
option :host_field,
|
84
91
|
:description => "InfluxDB measurement host field (default: host)",
|
85
92
|
:long => "--host-field <FIELD>",
|
@@ -197,35 +204,42 @@ class CheckInfluxDbQ < Sensu::Plugin::Check::CLI
|
|
197
204
|
@clients.each do |client|
|
198
205
|
query = config[:query].gsub(" WHERE ", " WHERE #{config[:host_field]} = '#{client}' AND ")
|
199
206
|
begin
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
207
|
+
timeout(config[:timeout) do
|
208
|
+
begin
|
209
|
+
records = @influxdb.query(query)
|
210
|
+
records.each do |record|
|
211
|
+
if @json_path
|
212
|
+
value = @json_path.on(record).first
|
213
|
+
|
214
|
+
record_s = record.symbolize_recursive
|
215
|
+
check_name = "influxdb-q-#{interpolate(config[:check_name], record_s)}"
|
216
|
+
msg = interpolate(config[:msg], record_s)
|
217
|
+
|
218
|
+
if value != nil
|
219
|
+
if config[:crit] and @calculator.evaluate(config[:crit], value: value)
|
220
|
+
send_critical(check_name, client, "#{msg} - Value: #{value} (#{config[:crit]})")
|
221
|
+
elsif config[:warn] and @calculator.evaluate(config[:warn], value: value)
|
222
|
+
send_warning(check_name, client, "#{msg} - Value: #{value} (#{config[:warn]})")
|
223
|
+
else
|
224
|
+
send_ok(check_name, client, "#{msg} - Value: #{value}")
|
225
|
+
end
|
226
|
+
else
|
227
|
+
send_unknown(check_name, client, "#{msg} - Value: N/A")
|
228
|
+
end
|
214
229
|
else
|
215
|
-
|
230
|
+
puts "InfluxDB query [#{query}] held the following result (use --json-path to retrieve a single value)"
|
231
|
+
puts
|
232
|
+
puts JSON.pretty_generate(record)
|
233
|
+
puts
|
216
234
|
end
|
217
|
-
else
|
218
|
-
send_unknown(check_name, client, "#{msg} - Value: N/A")
|
219
235
|
end
|
220
|
-
|
221
|
-
puts
|
222
|
-
|
223
|
-
puts JSON.pretty_generate(record)
|
224
|
-
puts
|
236
|
+
rescue
|
237
|
+
STDERR.puts($!)
|
238
|
+
problems += 1
|
225
239
|
end
|
226
240
|
end
|
227
|
-
rescue
|
228
|
-
STDERR.puts(
|
241
|
+
rescue Timeout::Error
|
242
|
+
STDERR.puts("InfluxDB query [#{query}] timed out")
|
229
243
|
problems += 1
|
230
244
|
end
|
231
245
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-influxdb-q
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Cerutti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|