sensu-plugins-influxdb-q 0.0.8 → 0.0.9
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 +4 -0
- data/bin/check-influxdb-q.rb +7 -35
- data/lib/sensu-plugins-influxdb-q/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a207bedffba13414bbd4291fcbbd5af979e0b61a
|
4
|
+
data.tar.gz: 5be5fd44bb84c35f31180541542eea43031c25bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5f53e431be469a13b8099cdf168d633cff22516790cbc35f977ea9c0a9bd81ab648c2750809cd9faffb6a97b957c9ca05c5d803aaca3d2ec292214717ab7b82
|
7
|
+
data.tar.gz: 1ea90d9ec7b02e92ff60c5ac25610eac14f8ffa8ba51e44b36f68cb2cd804a516598cf8b1e92f9e1b4ef1db2a555375124404c6935c0f7a4b904044eaae7d679
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@ 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
|
+
## [0.0.9] - 2016-01-18
|
7
|
+
### Added
|
8
|
+
- Not filtering by sensu clients anymore
|
9
|
+
|
6
10
|
## [0.0.8] - 2016-01-18
|
7
11
|
### Added
|
8
12
|
- Not filtering by sensu clients anymore
|
data/bin/check-influxdb-q.rb
CHANGED
@@ -92,12 +92,6 @@ class CheckInfluxDbQ < Sensu::Plugin::Check::CLI
|
|
92
92
|
:long => "--host-field <FIELD>",
|
93
93
|
:default => "host"
|
94
94
|
|
95
|
-
option :only_sensu_clients,
|
96
|
-
:description => "Only consider measurements of known sensu clients",
|
97
|
-
:long => "--only-sensu-clients",
|
98
|
-
:boolean => true
|
99
|
-
:default => false
|
100
|
-
|
101
95
|
option :handlers,
|
102
96
|
:description => "Comma separated list of handlers",
|
103
97
|
:long => "--handlers <HANDLER>",
|
@@ -139,9 +133,6 @@ class CheckInfluxDbQ < Sensu::Plugin::Check::CLI
|
|
139
133
|
@json_path = nil
|
140
134
|
end
|
141
135
|
@influxdb = InfluxDB::Client.new(cfg)
|
142
|
-
|
143
|
-
# get list of hosts
|
144
|
-
@clients = get_clients()
|
145
136
|
end
|
146
137
|
|
147
138
|
def send_client_socket(data)
|
@@ -190,34 +181,15 @@ class CheckInfluxDbQ < Sensu::Plugin::Check::CLI
|
|
190
181
|
string.gsub(/%\{([^\}]*)\}/).each { |match| match[/^%{(.*)}$/, 1].split('.').inject(hash) { |h, k| h[(k.to_s == k.to_i.to_s) ? k.to_i : k.to_sym] } }
|
191
182
|
end
|
192
183
|
|
193
|
-
def get_clients()
|
194
|
-
clients = []
|
195
|
-
|
196
|
-
if req = api_request(:GET, "/clients")
|
197
|
-
if req.code == '200'
|
198
|
-
JSON.parse(req.body).each do |client|
|
199
|
-
clients << client['name']
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
clients
|
205
|
-
end
|
206
|
-
|
207
184
|
def run()
|
208
|
-
problems = 0
|
209
|
-
|
210
185
|
begin
|
211
186
|
timeout(config[:timeout]) do
|
212
187
|
begin
|
213
|
-
records = @influxdb.query(query)
|
188
|
+
records = @influxdb.query(config[:query])
|
214
189
|
if records.size > 0
|
215
190
|
records.each do |record|
|
216
|
-
if record.has_key?(config[:host_field])
|
217
|
-
client = record[config[:host_field]]
|
218
|
-
|
219
|
-
# skip client if it's not already known by Sensu
|
220
|
-
next if config[:only_sensu_clients] and ! @clients.include?(client)
|
191
|
+
if record['tags'].has_key?(config[:host_field])
|
192
|
+
client = record['tags'][config[:host_field]]
|
221
193
|
else
|
222
194
|
client = nil
|
223
195
|
end
|
@@ -241,21 +213,21 @@ class CheckInfluxDbQ < Sensu::Plugin::Check::CLI
|
|
241
213
|
send_unknown(check_name, client, "#{msg} - Value: N/A")
|
242
214
|
end
|
243
215
|
else
|
244
|
-
puts "InfluxDB query [#{query}] held the following result (use --json-path to retrieve a single value)"
|
216
|
+
puts "InfluxDB query [#{config[:query]}] held the following result (use --json-path to retrieve a single value)"
|
245
217
|
puts
|
246
218
|
puts JSON.pretty_generate(record)
|
247
219
|
puts
|
248
220
|
end
|
249
221
|
end
|
250
222
|
else
|
251
|
-
unknown("InfluxDB query [#{query}] held no results")
|
223
|
+
unknown("InfluxDB query [#{config[:query]}] held no results")
|
252
224
|
end
|
253
225
|
rescue
|
254
|
-
critical("InfluxDB query [#{query}] failed - (#{$!})")
|
226
|
+
critical("InfluxDB query [#{config[:query]}] failed - (#{$!})")
|
255
227
|
end
|
256
228
|
end
|
257
229
|
rescue Timeout::Error
|
258
|
-
unknown("InfluxDB query [#{query}] timed out")
|
230
|
+
unknown("InfluxDB query [#{config[:query]}] timed out")
|
259
231
|
end
|
260
232
|
|
261
233
|
ok("Query executed successfully")
|