sensu-plugins-aws 13.0.0 → 14.0.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 +10 -2
- data/bin/check-elb-sum-requests.rb +26 -38
- data/lib/sensu-plugins-aws/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: e4c125fe85336325c696743b86e583d8dd5f15bc
|
4
|
+
data.tar.gz: f47506bebde25ee38b67630caa56c79b6fe17beb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41a57b823a533d2c30ae145e7a23ca7f5b4ab96103d648cf2f030efbd7bc12215c0e1ceaabbbd07f5d05d9e3c1a024d07c6cf074332c28d69bc177c076295cea
|
7
|
+
data.tar.gz: 75858702513638477429cc66226c8442ccf71d655f570105f3e7785d9d02f34be51368bac69dccfc122c5d9bffe879339707ca3e4aa60305ae70775d6c5cd31f
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,13 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [14.0.0] - 2018-11-01
|
9
|
+
### Breaking Changes
|
10
|
+
- `check-elb-sum-requests.rb` no longer takes `aws_access_key` and `aws_secret_access_key` options. (@boutetnico)
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- `check-elb-sum-requests.rb` was updated to aws-sdk v2. (@boutetnico)
|
14
|
+
|
8
15
|
## [13.0.0] - 2018-11-01
|
9
16
|
### Breaking Changes
|
10
17
|
- `check-redshift-events.rb` no longer takes `aws_access_key` and `aws_secret_access_key` options. (@boutetnico)
|
@@ -26,7 +33,7 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
26
33
|
|
27
34
|
## [12.1.0] - 2018-08-28
|
28
35
|
### Added
|
29
|
-
- new `check-efs.rb
|
36
|
+
- new `check-efs.rb`: checks cloudwatch metrics with the efs namespace for an arbitrary metric (@ivanfetch)
|
30
37
|
|
31
38
|
## [12.0.0] - 2018-06-21
|
32
39
|
### Breaking Changes
|
@@ -513,7 +520,8 @@ WARNING: This release contains major breaking changes that will impact all user
|
|
513
520
|
### Added
|
514
521
|
- initial release
|
515
522
|
|
516
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/
|
523
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/14.0.0...HEAD
|
524
|
+
[14.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/13.0.0...14.0.0
|
517
525
|
[13.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/12.4.0...13.0.0
|
518
526
|
[12.4.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/12.3.0...12.4.0
|
519
527
|
[12.3.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/12.2.0...12.3.0
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# Linux
|
13
13
|
#
|
14
14
|
# DEPENDENCIES:
|
15
|
-
# gem: aws-sdk
|
15
|
+
# gem: aws-sdk
|
16
16
|
# gem: sensu-plugin
|
17
17
|
#
|
18
18
|
# USAGE:
|
@@ -31,20 +31,11 @@
|
|
31
31
|
#
|
32
32
|
|
33
33
|
require 'sensu-plugin/check/cli'
|
34
|
-
require '
|
34
|
+
require 'sensu-plugins-aws'
|
35
|
+
require 'aws-sdk'
|
35
36
|
|
36
37
|
class CheckELBSumRequests < Sensu::Plugin::Check::CLI
|
37
|
-
|
38
|
-
short: '-a AWS_ACCESS_KEY',
|
39
|
-
long: '--aws-access-key AWS_ACCESS_KEY',
|
40
|
-
description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
|
41
|
-
default: ENV['AWS_ACCESS_KEY']
|
42
|
-
|
43
|
-
option :aws_secret_access_key,
|
44
|
-
short: '-k AWS_SECRET_KEY',
|
45
|
-
long: '--aws-secret-access-key AWS_SECRET_KEY',
|
46
|
-
description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
|
47
|
-
default: ENV['AWS_SECRET_KEY']
|
38
|
+
include Common
|
48
39
|
|
49
40
|
option :aws_region,
|
50
41
|
short: '-r AWS_REGION',
|
@@ -79,42 +70,40 @@ class CheckELBSumRequests < Sensu::Plugin::Check::CLI
|
|
79
70
|
description: "Trigger a #{severity} if sum requests is over specified count"
|
80
71
|
end
|
81
72
|
|
82
|
-
def aws_config
|
83
|
-
{ access_key_id: config[:aws_access_key],
|
84
|
-
secret_access_key: config[:aws_secret_access_key],
|
85
|
-
region: config[:aws_region] }
|
86
|
-
end
|
87
|
-
|
88
73
|
def elb
|
89
|
-
@elb ||=
|
74
|
+
@elb ||= Aws::ElasticLoadBalancing::Client.new(aws_config)
|
90
75
|
end
|
91
76
|
|
92
77
|
def cloud_watch
|
93
|
-
@cloud_watch ||=
|
78
|
+
@cloud_watch ||= Aws::CloudWatch::Client.new
|
94
79
|
end
|
95
80
|
|
96
81
|
def elbs
|
97
82
|
return @elbs if @elbs
|
98
|
-
@elbs = elb.
|
99
|
-
@elbs.select! { |elb| config[:elb_names].include? elb.
|
83
|
+
@elbs = elb.describe_load_balancers.load_balancer_descriptions.to_a
|
84
|
+
@elbs.select! { |elb| config[:elb_names].include? elb.load_balancer_name } if config[:elb_names]
|
100
85
|
@elbs
|
101
86
|
end
|
102
87
|
|
103
|
-
def
|
104
|
-
cloud_watch.
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
88
|
+
def request_count_metric(elb_name)
|
89
|
+
cloud_watch.get_metric_statistics(
|
90
|
+
namespace: 'AWS/ELB',
|
91
|
+
metric_name: 'RequestCount',
|
92
|
+
dimensions: [
|
93
|
+
{
|
94
|
+
name: 'LoadBalancerName',
|
95
|
+
value: elb_name
|
96
|
+
}
|
97
|
+
],
|
109
98
|
start_time: config[:end_time] - config[:period],
|
110
|
-
end_time:
|
99
|
+
end_time: config[:end_time],
|
111
100
|
statistics: ['Sum'],
|
112
|
-
period:
|
113
|
-
|
101
|
+
period: config[:period]
|
102
|
+
)
|
114
103
|
end
|
115
104
|
|
116
105
|
def latest_value(metric)
|
117
|
-
metric.
|
106
|
+
metric.datapoints.sort_by { |datapoint| datapoint[:timestamp] }.last[:sum]
|
118
107
|
end
|
119
108
|
|
120
109
|
def flag_alert(severity, message)
|
@@ -123,7 +112,7 @@ class CheckELBSumRequests < Sensu::Plugin::Check::CLI
|
|
123
112
|
end
|
124
113
|
|
125
114
|
def check_sum_requests(elb)
|
126
|
-
metric =
|
115
|
+
metric = request_count_metric elb.load_balancer_name
|
127
116
|
metric_value = begin
|
128
117
|
latest_value metric
|
129
118
|
rescue StandardError
|
@@ -132,18 +121,17 @@ class CheckELBSumRequests < Sensu::Plugin::Check::CLI
|
|
132
121
|
|
133
122
|
@severities.each_key do |severity|
|
134
123
|
threshold = config[:"#{severity}_over"]
|
135
|
-
puts metric_value
|
136
124
|
next unless threshold
|
137
125
|
next if metric_value < threshold
|
138
126
|
flag_alert severity,
|
139
|
-
"; #{elbs.size == 1 ? nil : "#{elb.
|
127
|
+
"; #{elbs.size == 1 ? nil : "#{elb.load_balancer_name}'s"} Sum Requests is #{metric_value}. (expected lower than #{threshold})"
|
140
128
|
break
|
141
129
|
end
|
142
130
|
end
|
143
131
|
|
144
132
|
def run
|
145
133
|
@message = if elbs.size == 1
|
146
|
-
elbs.first.
|
134
|
+
elbs.first.load_balancer_name
|
147
135
|
else
|
148
136
|
"#{elbs.size} load balancers total"
|
149
137
|
end
|
@@ -155,7 +143,7 @@ class CheckELBSumRequests < Sensu::Plugin::Check::CLI
|
|
155
143
|
|
156
144
|
elbs.each { |elb| check_sum_requests elb }
|
157
145
|
|
158
|
-
@message += "; (
|
146
|
+
@message += "; (Sum within #{config[:period]} seconds "
|
159
147
|
@message += "between #{config[:end_time] - config[:period]} to #{config[:end_time]})"
|
160
148
|
|
161
149
|
if @severities[:critical]
|