sensu-plugins-azurerm 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/bin/check-azurerm-monitor-metric.rb +117 -27
- data/lib/sensu-plugins-azurerm/version.rb +1 -1
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c0d821b364b1f014fc8bd22be6ab36099ebf97d153d1285b47f29b09babd7c5
|
4
|
+
data.tar.gz: 3749b5a3f31d8d81097c4544d76428f5fbdf44daf681b4dc35f22b37ef023bfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bb2b51fc3cbb14ba2b667414ce71582c28e70a6ce7d5c7af1919345e1624e87e0fed9f6c5ce6a4c4cdc5028b74ab3f91d9f5dfbc9656e49cbbb01858ac0450b
|
7
|
+
data.tar.gz: c4570fabb5ee1cd9e8003e6245a18dcc9f2adfb4466907cd5231d7bad560c6e012df63d7cbf391e43598ea5966ea43b4e6168a71b965cbef5cc0906ca5a4ecae
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,10 @@ This CHANGELOG follows the format located [here](https://github.com/sensu-plugin
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [3.1.0] - 2019-03-04
|
9
|
+
### Added
|
10
|
+
- check-azurerm-monitor-metric.rb: added `--aggregate_results aggregation_type TYPE` option that allows users to aggregate results returned from Azure DB query @MrMisa93
|
11
|
+
|
8
12
|
## [3.0.0] - 2018-09-15
|
9
13
|
### Security
|
10
14
|
- updated `yard` dependency to `~> 0.9.11` per: https://nvd.nist.gov/vuln/detail/CVE-2017-17042 which closes attacks against a yard server loading arbitrary files (@majormoses)
|
@@ -94,7 +98,8 @@ This CHANGELOG follows the format located [here](https://github.com/sensu-plugin
|
|
94
98
|
### Added
|
95
99
|
- initial release
|
96
100
|
|
97
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-azurerm/compare/3.
|
101
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-azurerm/compare/3.1.0..HEAD
|
102
|
+
[3.1.0]: https://github.com/sensu-plugins/sensu-plugins-azurerm/compare/3.0.0..3.1.0
|
98
103
|
[3.0.0]: https://github.com/sensu-plugins/sensu-plugins-azurerm/compare/2.1.0..3.0.0
|
99
104
|
[2.1.0]: https://github.com/sensu-plugins/sensu-plugins-azurerm/compare/2.0.0...2.1.0
|
100
105
|
[2.0.0]: https://github.com/sensu-plugins/sensu-plugins-azurerm/compare/1.0.0..2.0.0
|
@@ -127,11 +127,18 @@ class CheckAzurermMonitorMetric < Sensu::Plugin::Check::CLI
|
|
127
127
|
short: '-f FILTER',
|
128
128
|
long: '--filter FILTER'
|
129
129
|
|
130
|
-
option :
|
131
|
-
description: '
|
130
|
+
option :request_aggregation,
|
131
|
+
description: 'Used as a parameter to the HTTP request sent to Azure. This can be average, count, maximum, minimum, total',
|
132
132
|
short: '-a aggregation',
|
133
133
|
long: '--aggregation aggregation',
|
134
|
-
default: 'average'
|
134
|
+
default: 'average',
|
135
|
+
in: %w[average count maximum minimum total]
|
136
|
+
|
137
|
+
option :aggregate_results,
|
138
|
+
description: 'Aggregate the result data points to compare against alert conditions. This can be average, count, maximum, minimum, total',
|
139
|
+
long: '--aggregate_results aggregation_type',
|
140
|
+
default: 'none',
|
141
|
+
in: %w[average count maximum minimum total none]
|
135
142
|
|
136
143
|
option :warning_over,
|
137
144
|
description: 'The warning threshold to check if the metric is forecasted to go over.',
|
@@ -178,31 +185,35 @@ class CheckAzurermMonitorMetric < Sensu::Plugin::Check::CLI
|
|
178
185
|
unknown 'At least one threshold must be provided.'
|
179
186
|
end
|
180
187
|
|
181
|
-
if
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
188
|
+
if config[:aggregate_results] == 'none'
|
189
|
+
if last_metric_values.empty?
|
190
|
+
unknown "There are no metric values for #{config[:metric]} on resource #{config[:resource_id] || config[:resource_name]} with aggregation #{config[:aggregation]}"
|
191
|
+
else
|
192
|
+
critical_messages = []
|
193
|
+
warning_messages = []
|
194
|
+
|
195
|
+
last_metric_values.each do |metric_val|
|
196
|
+
if config[:critical_over] && metric_val[:value] > config[:critical_over].to_f
|
197
|
+
critical_messages << "Metric #{metric_val[:metric_name]} is #{metric_val[:value]}"
|
198
|
+
elsif config[:warning_over] && metric_val[:value] > config[:warning_over].to_f
|
199
|
+
warning_messages << "Metric #{metric_val[:metric_name]} is #{metric_val[:value]}"
|
200
|
+
elsif config[:critical_under] && metric_val[:value] < config[:critical_under].to_f
|
201
|
+
critical_messages << "Metric #{metric_val[:metric_name]} is #{metric_val[:value]}"
|
202
|
+
elsif config[:warning_under] && metric_val[:value] < config[:warning_under].to_f
|
203
|
+
warning_messages << "Metric #{metric_val[:metric_name]} is #{metric_val[:value]}"
|
204
|
+
end
|
196
205
|
end
|
197
|
-
end
|
198
206
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
207
|
+
if !critical_messages.empty?
|
208
|
+
critical critical_messages.join("\n")
|
209
|
+
elsif !warning_messages.empty?
|
210
|
+
warning warning_messages.join("\n")
|
211
|
+
else
|
212
|
+
ok 'Metric(s) are within thresholds'
|
213
|
+
end
|
205
214
|
end
|
215
|
+
else
|
216
|
+
verify_results_with_aggregation
|
206
217
|
end
|
207
218
|
end
|
208
219
|
|
@@ -264,7 +275,7 @@ class CheckAzurermMonitorMetric < Sensu::Plugin::Check::CLI
|
|
264
275
|
end
|
265
276
|
|
266
277
|
def metric_value_key
|
267
|
-
config[:
|
278
|
+
config[:request_aggregation].to_sym
|
268
279
|
end
|
269
280
|
|
270
281
|
def metric_response
|
@@ -297,7 +308,7 @@ class CheckAzurermMonitorMetric < Sensu::Plugin::Check::CLI
|
|
297
308
|
"api-version=#{AZURE_API_VER}&" \
|
298
309
|
"metric=#{config[:metric]}&" \
|
299
310
|
"timespan=#{CGI.escape(timespan)}&" \
|
300
|
-
"aggregation=#{config[:
|
311
|
+
"aggregation=#{config[:request_aggregation]}"
|
301
312
|
|
302
313
|
url += "&$filter=#{CGI.escape(config[:filter])}" if config[:filter]
|
303
314
|
|
@@ -353,4 +364,83 @@ class CheckAzurermMonitorMetric < Sensu::Plugin::Check::CLI
|
|
353
364
|
def handle_response(res)
|
354
365
|
critical "Failed to get metric:\n#{res.body}" if res.code.to_i >= 300
|
355
366
|
end
|
367
|
+
|
368
|
+
def verify_results_with_aggregation
|
369
|
+
request_values = extract_request_values
|
370
|
+
|
371
|
+
aggregated_value = aggregate_request_values(request_values, config[:aggregate_results])
|
372
|
+
|
373
|
+
results_type = verify_result(aggregated_value)
|
374
|
+
|
375
|
+
exits_with_message(results_type, request_values[0][:name], aggregated_value)
|
376
|
+
end
|
377
|
+
|
378
|
+
def extract_request_values
|
379
|
+
values = []
|
380
|
+
metric_response[:value].each do |metric_resp_value|
|
381
|
+
name = metric_resp_value[:name] ? metric_resp_value[:name][:value] : ''
|
382
|
+
|
383
|
+
next if metric_resp_value[:timeseries].empty?
|
384
|
+
|
385
|
+
metric_resp_value[:timeseries].each do |ts|
|
386
|
+
ts[:data].each do |metric_value|
|
387
|
+
if metric_value[metric_value_key]
|
388
|
+
values << {
|
389
|
+
value: metric_value[metric_value_key].to_f,
|
390
|
+
name: name
|
391
|
+
}
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
end
|
396
|
+
values
|
397
|
+
end
|
398
|
+
|
399
|
+
def aggregate_request_values(request_values, aggregation_type)
|
400
|
+
result_values = []
|
401
|
+
|
402
|
+
request_values.each do |metric_val|
|
403
|
+
result_values.push(metric_val[:value])
|
404
|
+
end
|
405
|
+
|
406
|
+
case aggregation_type
|
407
|
+
when 'average'
|
408
|
+
result_value = result_values.inject { |sum, el| sum + el }.to_f / result_values.size
|
409
|
+
when 'maximum'
|
410
|
+
result_value = result_values.max
|
411
|
+
when 'minimum'
|
412
|
+
result_value = result_values.min
|
413
|
+
when 'total'
|
414
|
+
result_value = result_values.inject(0) { |sum, x| sum + x }
|
415
|
+
when 'count'
|
416
|
+
result_value = result_values.size
|
417
|
+
end
|
418
|
+
result_value
|
419
|
+
end
|
420
|
+
|
421
|
+
def verify_result(aggregated_value)
|
422
|
+
results_type = 'none'
|
423
|
+
if config[:critical_over] && aggregated_value > config[:critical_over].to_f
|
424
|
+
results_type = 'critical'
|
425
|
+
elsif config[:warning_over] && aggregated_value > config[:warning_over].to_f
|
426
|
+
results_type = 'warning'
|
427
|
+
elsif config[:critical_under] && aggregated_value < config[:critical_under].to_f
|
428
|
+
results_type = 'critical'
|
429
|
+
elsif config[:warning_under] && aggregated_value < config[:warning_under].to_f
|
430
|
+
results_type = 'warning'
|
431
|
+
end
|
432
|
+
results_type
|
433
|
+
end
|
434
|
+
|
435
|
+
def exits_with_message(type, metric_name, aggregated_value)
|
436
|
+
message = "Metric #{metric_name} is #{aggregated_value}"
|
437
|
+
case type
|
438
|
+
when 'none'
|
439
|
+
ok 'Metric(s) are within thresholds'
|
440
|
+
when 'warning'
|
441
|
+
warning message
|
442
|
+
when 'critical'
|
443
|
+
critical message
|
444
|
+
end
|
445
|
+
end
|
356
446
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-azurerm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Harvey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: azure_mgmt_compute
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '3.0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '3.0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: kitchen-docker
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,22 +154,22 @@ dependencies:
|
|
154
154
|
name: mixlib-shellout
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "<"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: 2.3.0
|
160
157
|
- - "~>"
|
161
158
|
- !ruby/object:Gem::Version
|
162
159
|
version: '2.2'
|
160
|
+
- - "<"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 2.3.0
|
163
163
|
type: :development
|
164
164
|
prerelease: false
|
165
165
|
version_requirements: !ruby/object:Gem::Requirement
|
166
166
|
requirements:
|
167
|
-
- - "<"
|
168
|
-
- !ruby/object:Gem::Version
|
169
|
-
version: 2.3.0
|
170
167
|
- - "~>"
|
171
168
|
- !ruby/object:Gem::Version
|
172
169
|
version: '2.2'
|
170
|
+
- - "<"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 2.3.0
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
174
|
name: pry
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,14 +190,14 @@ dependencies:
|
|
190
190
|
requirements:
|
191
191
|
- - "~>"
|
192
192
|
- !ruby/object:Gem::Version
|
193
|
-
version: '
|
193
|
+
version: '12.3'
|
194
194
|
type: :development
|
195
195
|
prerelease: false
|
196
196
|
version_requirements: !ruby/object:Gem::Requirement
|
197
197
|
requirements:
|
198
198
|
- - "~>"
|
199
199
|
- !ruby/object:Gem::Version
|
200
|
-
version: '
|
200
|
+
version: '12.3'
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: rdoc
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -394,8 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
394
394
|
- !ruby/object:Gem::Version
|
395
395
|
version: '0'
|
396
396
|
requirements: []
|
397
|
-
|
398
|
-
rubygems_version: 2.7.7
|
397
|
+
rubygems_version: 3.0.3
|
399
398
|
signing_key:
|
400
399
|
specification_version: 4
|
401
400
|
summary: Sensu plugins for working with an Azure Resource Manager environment
|