sensu-plugins-aws 14.0.0 → 15.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 +8 -1
- data/bin/check-elb-latency.rb +26 -36
- 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: 88538012dc8a180460b5940bcdd1da6888a589c5
|
4
|
+
data.tar.gz: 6c54d7bf29e80f548b3ea9c82500c8ba92d8e98a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6d595483bf559aa7a2e647f7cb01100fa5cdfb99bf2eba5c6e74b6b4f59fe047e452e0c5c603c1b2b062b2e5d724adead5c012b49fce7419f2297e748ab2987
|
7
|
+
data.tar.gz: 794ca978c9026de692fcdb46bc1fd4ee357f1d404fbfb7898dafb89afd7ce0e86d667cda1b73434ede27f8921c69d770b66619b6bd2d9bd2e5d90356b2eb5ddc
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [15.0.0] - 2018-11-01
|
9
|
+
### Breaking Changes
|
10
|
+
- `check-elb-latency.rb` no longer takes `aws_access_key` and `aws_secret_access_key` options. (@boutetnico)
|
11
|
+
### Changed
|
12
|
+
- `check-elb-latency.rb` was updated to aws-sdk v2. (@boutetnico)
|
13
|
+
|
8
14
|
## [14.0.0] - 2018-11-01
|
9
15
|
### Breaking Changes
|
10
16
|
- `check-elb-sum-requests.rb` no longer takes `aws_access_key` and `aws_secret_access_key` options. (@boutetnico)
|
@@ -520,7 +526,8 @@ WARNING: This release contains major breaking changes that will impact all user
|
|
520
526
|
### Added
|
521
527
|
- initial release
|
522
528
|
|
523
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/
|
529
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/15.0.0...HEAD
|
530
|
+
[15.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/14.0.0...15.0.0
|
524
531
|
[14.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/13.0.0...14.0.0
|
525
532
|
[13.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/12.4.0...13.0.0
|
526
533
|
[12.4.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/12.3.0...12.4.0
|
data/bin/check-elb-latency.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
#
|
6
6
|
# DESCRIPTION:
|
7
|
-
# This plugin checks the
|
7
|
+
# This plugin checks the latency of an Amazon Elastic Load Balancer.
|
8
8
|
#
|
9
9
|
# OUTPUT:
|
10
10
|
# plain-text
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# Linux
|
14
14
|
#
|
15
15
|
# DEPENDENCIES:
|
16
|
-
# gem: aws-sdk
|
16
|
+
# gem: aws-sdk
|
17
17
|
# gem: sensu-plugin
|
18
18
|
#
|
19
19
|
# USAGE:
|
@@ -32,20 +32,11 @@
|
|
32
32
|
#
|
33
33
|
|
34
34
|
require 'sensu-plugin/check/cli'
|
35
|
-
require '
|
35
|
+
require 'sensu-plugins-aws'
|
36
|
+
require 'aws-sdk'
|
36
37
|
|
37
38
|
class CheckELBLatency < Sensu::Plugin::Check::CLI
|
38
|
-
|
39
|
-
short: '-a AWS_ACCESS_KEY',
|
40
|
-
long: '--aws-access-key AWS_ACCESS_KEY',
|
41
|
-
description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
|
42
|
-
default: ENV['AWS_ACCESS_KEY']
|
43
|
-
|
44
|
-
option :aws_secret_access_key,
|
45
|
-
short: '-k AWS_SECRET_KEY',
|
46
|
-
long: '--aws-secret-access-key AWS_SECRET_KEY',
|
47
|
-
description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
|
48
|
-
default: ENV['AWS_SECRET_KEY']
|
39
|
+
include Common
|
49
40
|
|
50
41
|
option :aws_region,
|
51
42
|
short: '-r AWS_REGION',
|
@@ -87,42 +78,41 @@ class CheckELBLatency < Sensu::Plugin::Check::CLI
|
|
87
78
|
description: "Trigger a #{severity} if latancy is over specified seconds"
|
88
79
|
end
|
89
80
|
|
90
|
-
def aws_config
|
91
|
-
{ access_key_id: config[:aws_access_key],
|
92
|
-
secret_access_key: config[:aws_secret_access_key],
|
93
|
-
region: config[:aws_region] }
|
94
|
-
end
|
95
|
-
|
96
81
|
def elb
|
97
|
-
@elb ||=
|
82
|
+
@elb ||= Aws::ElasticLoadBalancing::Client.new(aws_config)
|
98
83
|
end
|
99
84
|
|
100
85
|
def cloud_watch
|
101
|
-
@cloud_watch ||=
|
86
|
+
@cloud_watch ||= Aws::CloudWatch::Client.new
|
102
87
|
end
|
103
88
|
|
104
89
|
def elbs
|
105
90
|
return @elbs if @elbs
|
106
|
-
@elbs = elb.
|
107
|
-
@elbs.select! { |elb| config[:elb_names].include? elb.
|
91
|
+
@elbs = elb.describe_load_balancers.load_balancer_descriptions.to_a
|
92
|
+
@elbs.select! { |elb| config[:elb_names].include? elb.load_balancer_name } if config[:elb_names]
|
108
93
|
@elbs
|
109
94
|
end
|
110
95
|
|
111
96
|
def latency_metric(elb_name)
|
112
|
-
cloud_watch.
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
97
|
+
cloud_watch.get_metric_statistics(
|
98
|
+
namespace: 'AWS/ELB',
|
99
|
+
metric_name: 'Latency',
|
100
|
+
dimensions: [
|
101
|
+
{
|
102
|
+
name: 'LoadBalancerName',
|
103
|
+
value: elb_name
|
104
|
+
}
|
105
|
+
],
|
117
106
|
start_time: config[:end_time] - config[:period],
|
118
|
-
end_time:
|
107
|
+
end_time: config[:end_time],
|
119
108
|
statistics: [config[:statistics].to_s.capitalize],
|
120
|
-
period:
|
121
|
-
|
109
|
+
period: config[:period],
|
110
|
+
unit: 'Seconds'
|
111
|
+
)
|
122
112
|
end
|
123
113
|
|
124
114
|
def latest_value(metric)
|
125
|
-
metric.
|
115
|
+
metric.datapoints.sort_by { |datapoint| datapoint[:timestamp] }.last[config[:statistics]]
|
126
116
|
end
|
127
117
|
|
128
118
|
def flag_alert(severity, message)
|
@@ -131,7 +121,7 @@ class CheckELBLatency < Sensu::Plugin::Check::CLI
|
|
131
121
|
end
|
132
122
|
|
133
123
|
def check_latency(elb)
|
134
|
-
metric = latency_metric elb.
|
124
|
+
metric = latency_metric elb.load_balancer_name
|
135
125
|
metric_value = begin
|
136
126
|
latest_value metric
|
137
127
|
rescue StandardError
|
@@ -143,14 +133,14 @@ class CheckELBLatency < Sensu::Plugin::Check::CLI
|
|
143
133
|
next unless threshold
|
144
134
|
next if metric_value < threshold
|
145
135
|
flag_alert severity,
|
146
|
-
"; #{elbs.size == 1 ? nil : "#{elb.
|
136
|
+
"; #{elbs.size == 1 ? nil : "#{elb.load_balancer_name}'s"} Latency is #{sprintf '%.3f', metric_value} seconds. (expected lower than #{sprintf '%.3f', threshold})"
|
147
137
|
break
|
148
138
|
end
|
149
139
|
end
|
150
140
|
|
151
141
|
def run
|
152
142
|
@message = if elbs.size == 1
|
153
|
-
elbs.first.
|
143
|
+
elbs.first.load_balancer_name
|
154
144
|
else
|
155
145
|
"#{elbs.size} load balancers total"
|
156
146
|
end
|