sensu-plugins-aws-boutetnico 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/LICENSE +22 -0
- data/README.md +333 -0
- data/bin/check-alb-target-group-health.rb +100 -0
- data/bin/check-asg-instances-created.rb +129 -0
- data/bin/check-asg-instances-inservice.rb +109 -0
- data/bin/check-autoscaling-cpucredits.rb +160 -0
- data/bin/check-beanstalk-elb-metric.rb +123 -0
- data/bin/check-beanstalk-health.rb +123 -0
- data/bin/check-certificate-expiry.rb +123 -0
- data/bin/check-cloudfront-tag.rb +70 -0
- data/bin/check-cloudwatch-alarm.rb +102 -0
- data/bin/check-cloudwatch-alarms.rb +89 -0
- data/bin/check-cloudwatch-composite-metric.rb +199 -0
- data/bin/check-cloudwatch-metric.rb +123 -0
- data/bin/check-configservice-rules.rb +76 -0
- data/bin/check-direct-connect-virtual-interfaces.rb +84 -0
- data/bin/check-dynamodb-capacity.rb +194 -0
- data/bin/check-dynamodb-throttle.rb +188 -0
- data/bin/check-ebs-burst-limit.rb +143 -0
- data/bin/check-ebs-snapshots.rb +104 -0
- data/bin/check-ec2-cpu_balance.rb +139 -0
- data/bin/check-ec2-filter.rb +190 -0
- data/bin/check-ec2-network.rb +133 -0
- data/bin/check-ecs-service-health.rb +155 -0
- data/bin/check-efs-metric.rb +145 -0
- data/bin/check-eip-allocation.rb +64 -0
- data/bin/check-elasticache-failover.rb +113 -0
- data/bin/check-elb-certs.rb +132 -0
- data/bin/check-elb-health-fog.rb +114 -0
- data/bin/check-elb-health-sdk.rb +176 -0
- data/bin/check-elb-health.rb +116 -0
- data/bin/check-elb-instances-inservice.rb +103 -0
- data/bin/check-elb-latency.rb +166 -0
- data/bin/check-elb-nodes.rb +133 -0
- data/bin/check-elb-sum-requests.rb +157 -0
- data/bin/check-emr-cluster.rb +144 -0
- data/bin/check-emr-steps.rb +90 -0
- data/bin/check-eni-status.rb +110 -0
- data/bin/check-expiring-reservations.rb +117 -0
- data/bin/check-instance-events.rb +154 -0
- data/bin/check-instance-health.rb +108 -0
- data/bin/check-instance-reachability.rb +107 -0
- data/bin/check-instances-count.rb +94 -0
- data/bin/check-kms-key.rb +73 -0
- data/bin/check-rds-events.rb +141 -0
- data/bin/check-rds-pending.rb +91 -0
- data/bin/check-rds.rb +382 -0
- data/bin/check-redshift-events.rb +108 -0
- data/bin/check-reserved-instances.rb +80 -0
- data/bin/check-route.rb +122 -0
- data/bin/check-route53-domain-expiration.rb +78 -0
- data/bin/check-s3-bucket-visibility.rb +176 -0
- data/bin/check-s3-bucket.rb +86 -0
- data/bin/check-s3-object.rb +205 -0
- data/bin/check-s3-tag.rb +70 -0
- data/bin/check-sensu-client.rb +184 -0
- data/bin/check-ses-limit.rb +89 -0
- data/bin/check-ses-statistics.rb +149 -0
- data/bin/check-sns-subscriptions.rb +52 -0
- data/bin/check-sqs-messages.rb +168 -0
- data/bin/check-subnet-ip-consumption.rb +234 -0
- data/bin/check-trustedadvisor-service-limits.rb +90 -0
- data/bin/check-vpc-nameservers.rb +87 -0
- data/bin/check-vpc-vpn.rb +98 -0
- data/bin/handler-ec2_node.rb +241 -0
- data/bin/handler-scale-asg-down.rb +131 -0
- data/bin/handler-scale-asg-up.rb +131 -0
- data/bin/handler-ses.rb +107 -0
- data/bin/handler-sns.rb +64 -0
- data/bin/metrics-asg.rb +156 -0
- data/bin/metrics-autoscaling-instance-count.rb +101 -0
- data/bin/metrics-billing.rb +97 -0
- data/bin/metrics-cloudfront.rb +159 -0
- data/bin/metrics-ec2-count.rb +137 -0
- data/bin/metrics-ec2-filter.rb +97 -0
- data/bin/metrics-elasticache.rb +166 -0
- data/bin/metrics-elb.rb +169 -0
- data/bin/metrics-emr-steps.rb +82 -0
- data/bin/metrics-rds.rb +153 -0
- data/bin/metrics-reservation-utilization.rb +84 -0
- data/bin/metrics-s3.rb +107 -0
- data/bin/metrics-ses.rb +62 -0
- data/bin/metrics-sqs.rb +98 -0
- data/bin/metrics-waf.rb +111 -0
- data/lib/sensu-plugins-aws.rb +4 -0
- data/lib/sensu-plugins-aws/cloudwatch-common.rb +92 -0
- data/lib/sensu-plugins-aws/common.rb +35 -0
- data/lib/sensu-plugins-aws/filter.rb +47 -0
- data/lib/sensu-plugins-aws/version.rb +8 -0
- metadata +456 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 168687aadfb019212eefa8435fdff01ffdaf456323c96f2355e413087c836804
|
4
|
+
data.tar.gz: 2ae1bad36a33aa04dca6dcb0f2a146f3a3c572f3d31e3e5732d43c91534f567c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6a12c2639df2f1fee08c05f5e1816917c206de9f2f897d76246275f5e489745bca6f2ac2f4fc2dc07716b7bd8fd11c30f0003c28a8a1745ecfae8f9bb54d9ba8
|
7
|
+
data.tar.gz: 333597d48f09852e891c6b05781a0937ef8f720e59f1496b46caeca69a0e823f6b906bf6136482a45fbe8e3a973467b7082f2d592af33d90287357ee15d878bc
|
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Sensu-Plugins
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,333 @@
|
|
1
|
+
## Sensu-Plugins-aws
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/boutetnico/sensu-plugins-aws.svg?branch=master)](https://travis-ci.org/boutetnico/sensu-plugins-aws)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-aws-boutetnico.svg)](https://badge.fury.io/rb/sensu-plugins-aws-boutetnico.svg)
|
5
|
+
[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/boutetnico/sensu-plugins-aws)
|
6
|
+
|
7
|
+
## This is an unofficial fork
|
8
|
+
|
9
|
+
Due to the lack of activity from owners of [sensu-plugins-aws](https://github.com/sensu-plugins/sensu-plugins-aws) I have created this fork. It is automatically tested, built and published to [RubyGems](https://rubygems.org/gems/sensu-plugins-aws-boutetnico/) and [Bonsai](https://bonsai.sensu.io/assets/boutetnico/sensu-plugins-aws). It includes several new plugins as well as some improvements. Please check the changelog at the [GitHub Releases page](https://github.com/boutetnico/sensu-plugins-aws/releases).
|
10
|
+
|
11
|
+
## Sensu Asset
|
12
|
+
The Sensu assets packaged from this repository are built against the Sensu Ruby runtime environment. When using these assets as part of a Sensu Go resource (check, mutator or handler), make sure you include the corresponding Sensu Ruby runtime asset in the list of assets needed by the resource. The current ruby-runtime assets can be found [here](https://bonsai.sensu.io/assets/sensu/sensu-ruby-runtime) in the [Bonsai Asset Index](bonsai.sensu.io).
|
13
|
+
|
14
|
+
## Functionality
|
15
|
+
|
16
|
+
**check-alb-target-group-health.rb**
|
17
|
+
|
18
|
+
**check-asg-instances-created.rb**
|
19
|
+
|
20
|
+
**check-asg-instances-inservice.rb**
|
21
|
+
|
22
|
+
**check-autoscaling-cpucredits.rb**
|
23
|
+
|
24
|
+
**check-beanstalk-elb-metric.rb**
|
25
|
+
|
26
|
+
**check-certificate-expiry.rb**
|
27
|
+
|
28
|
+
**check-cloudwatch-alarm**
|
29
|
+
|
30
|
+
**check-cloudwatch-alarms**
|
31
|
+
|
32
|
+
**check-cloudwatch-composite-metric**
|
33
|
+
|
34
|
+
**check-cloudwatch-metric**
|
35
|
+
|
36
|
+
**check-cloudfront-tag**
|
37
|
+
|
38
|
+
**check-configservice-rules**
|
39
|
+
|
40
|
+
**check-dynamodb-capacity.rb**
|
41
|
+
|
42
|
+
**check-dynamodb-throttle.rb**
|
43
|
+
|
44
|
+
**check-direct-connect-virtual-interfaces.rb**
|
45
|
+
|
46
|
+
**check-ebs-snapshots.rb**
|
47
|
+
|
48
|
+
**check-ebs-burst-limit.rb**
|
49
|
+
|
50
|
+
**check-ec2-cpu_balance.rb**
|
51
|
+
|
52
|
+
**check-ec2-filter.rb**
|
53
|
+
|
54
|
+
**check-ec2-network.rb**
|
55
|
+
|
56
|
+
**check-ecs-service-health.rb**
|
57
|
+
|
58
|
+
**check-efs-metric.rb**
|
59
|
+
|
60
|
+
**check-eip-allocation.rb**
|
61
|
+
|
62
|
+
**check-elasticache-failover.rb**
|
63
|
+
|
64
|
+
**check-elb-certs.rb**
|
65
|
+
|
66
|
+
**check-elb-health-fog.rb**
|
67
|
+
|
68
|
+
**check-elb-health-sdk.rb**
|
69
|
+
|
70
|
+
**check-elb-health.rb**
|
71
|
+
|
72
|
+
**check-elb-instances-inservice.rb**
|
73
|
+
|
74
|
+
**check-elb-latency.rb**
|
75
|
+
|
76
|
+
**check-elb-nodes.rb**
|
77
|
+
|
78
|
+
**check-elb-sum-requests.rb**
|
79
|
+
|
80
|
+
**check-emr-cluster.rb**
|
81
|
+
|
82
|
+
**check-emr-steps.rb**
|
83
|
+
|
84
|
+
**check-eni-status.rb**
|
85
|
+
|
86
|
+
**check-instance-events.rb**
|
87
|
+
|
88
|
+
**check-instance-health.rb**
|
89
|
+
|
90
|
+
**check-kms-key.rb**
|
91
|
+
|
92
|
+
**check-rds-events.rb**
|
93
|
+
|
94
|
+
**check-rds-pending.rb**
|
95
|
+
|
96
|
+
**check-rds.rb**
|
97
|
+
|
98
|
+
**check-redshift-events.rb**
|
99
|
+
|
100
|
+
**check-reserved-instances.rb**
|
101
|
+
|
102
|
+
**check-route53-domain-expiration.rb**
|
103
|
+
|
104
|
+
**check-s3-bucket.rb**
|
105
|
+
|
106
|
+
**check-s3-bucket-visibility.rb**
|
107
|
+
|
108
|
+
**check-s3-object.rb**
|
109
|
+
|
110
|
+
**check-s3-tag.rb**
|
111
|
+
|
112
|
+
**check-ses-limit.rb**
|
113
|
+
|
114
|
+
**check-ses-statistics.rb**
|
115
|
+
|
116
|
+
**check-sns-subscriptions**
|
117
|
+
|
118
|
+
**check-sqs-messages.rb**
|
119
|
+
|
120
|
+
**check-subnet-ip-consumption**
|
121
|
+
|
122
|
+
**check-vpc-nameservers**
|
123
|
+
|
124
|
+
**check-instances-count.rb**
|
125
|
+
|
126
|
+
**check-vpc-vpn.rb**
|
127
|
+
|
128
|
+
**handler-ec2_node.rb**
|
129
|
+
|
130
|
+
**handler-scale-asg-down.rb**
|
131
|
+
|
132
|
+
**handler-scale-asg-up.rb**
|
133
|
+
|
134
|
+
**handler-ses.rb**
|
135
|
+
|
136
|
+
**handler-sns.rb**
|
137
|
+
|
138
|
+
**metrics-asg.rb**
|
139
|
+
|
140
|
+
**metrics-autoscaling-instance-count.rb**
|
141
|
+
|
142
|
+
**metrics-billing.rb**
|
143
|
+
|
144
|
+
**metrics-ec2-count.rb**
|
145
|
+
|
146
|
+
**metrics-ec2-filter.rb**
|
147
|
+
|
148
|
+
**metrics-elasticache.rb**
|
149
|
+
|
150
|
+
**metrics-elb-full.rb**
|
151
|
+
|
152
|
+
**metrics-elb.rb**
|
153
|
+
|
154
|
+
**metrics-emr-steps.rb**
|
155
|
+
|
156
|
+
**metrics-rds.rb**
|
157
|
+
|
158
|
+
**metrics-s3.rb**
|
159
|
+
|
160
|
+
**metrics-ses.rb**
|
161
|
+
|
162
|
+
**metrics-sqs.rb**
|
163
|
+
|
164
|
+
|
165
|
+
## Files
|
166
|
+
|
167
|
+
* /bin/check-alb-target-group-health.rb
|
168
|
+
* /bin/check-asg-instances-created.rb
|
169
|
+
* /bin/check-autoscaling-cpucredits.rb
|
170
|
+
* /bin/check-asg-instances-inservice.rb
|
171
|
+
* /bin/check-beanstalk-elb-metric.rb
|
172
|
+
* /bin/check-certificate-expiry.rb
|
173
|
+
* /bin/check-configservice-rules.rb
|
174
|
+
* /bin/check-cloudfront-tag.rb
|
175
|
+
* /bin/check-cloudwatch-alarm.rb
|
176
|
+
* /bin/check-cloudwatch-metric.rb
|
177
|
+
* /bin/check-cloudwatch-composite-metric.rb
|
178
|
+
* /bin/check-dynamodb-capacity.rb
|
179
|
+
* /bin/check-dynamodb-throttle.rb
|
180
|
+
* /bin/check-direct-connect-virtual-interfaces.rb
|
181
|
+
* /bin/check-ebs-burst-limit.rb
|
182
|
+
* /bin/check-ebs-snapshots.rb
|
183
|
+
* /bin/check-ec2-filter.rb
|
184
|
+
* /bin/check-ec2-network.rb
|
185
|
+
* /bin/check-ecs-service-health.rb
|
186
|
+
* /bin/check-efs-metric.rb
|
187
|
+
* /bin/check-elasticache-failover.rb
|
188
|
+
* /bin/check-elb-certs.rb
|
189
|
+
* /bin/check-elb-health-fog.rb
|
190
|
+
* /bin/check-elb-health-sdk.rb
|
191
|
+
* /bin/check-elb-health.rb
|
192
|
+
* /bin/check-elb-instances-inservice.rb
|
193
|
+
* /bin/check-elb-latency.rb
|
194
|
+
* /bin/check-elb-nodes.rb
|
195
|
+
* /bin/check-elb-sum-requests.rb
|
196
|
+
* /bin/check-emr-cluster.rb
|
197
|
+
* /bin/check-emr-steps.rb
|
198
|
+
* /bin/check-eni-status.rb
|
199
|
+
* /bin/check-expiring-reservations.rb
|
200
|
+
* /bin/check-instance-events.rb
|
201
|
+
* /bin/check-rds-events.rb
|
202
|
+
* /bin/check-rds-pending.rb
|
203
|
+
* /bin/check-rds.rb
|
204
|
+
* /bin/check-redshift-events.rb
|
205
|
+
* /bin/check-route53-domain-expiration.rb
|
206
|
+
* /bin/check-s3-object.rb
|
207
|
+
* /bin/check-s3-tag.rb
|
208
|
+
* /bin/check-ses-limit.rb
|
209
|
+
* /bin/check-ses-statistics.rb
|
210
|
+
* /bin/check-sqs-messages.rb
|
211
|
+
* /bin/check-subnet-ip-consumption.rb
|
212
|
+
* /bin/check-vpc-nameservers.rb
|
213
|
+
* /bin/check_vpc_vpn.py
|
214
|
+
* /bin/check_vpc_vpn.rb
|
215
|
+
* /bin/handler-ec2_node.rb
|
216
|
+
* /bin/handler-ses.rb
|
217
|
+
* /bin/handler-sns.rb
|
218
|
+
* /bin/metrics-autoscaling-instance-count.rb
|
219
|
+
* /bin/check-instances-count.rb
|
220
|
+
* /bin/metrics-asg.rb
|
221
|
+
* /bin/metrics-billing.rb
|
222
|
+
* /bin/metrics-ec2-count.rb
|
223
|
+
* /bin/metrics-ec2-filter.rb
|
224
|
+
* /bin/metrics-elasticache.rb
|
225
|
+
* /bin/metrics-elb-full.rb
|
226
|
+
* /bin/metrics-elb.rb
|
227
|
+
* /bin/metrics-emr-steps.rb
|
228
|
+
* /bin/metrics-rds.rb
|
229
|
+
* /bin/metrics-reservation-utilization.rb
|
230
|
+
* /bin/metrics-s3.rb
|
231
|
+
* /bin/metrics-ses.rb
|
232
|
+
* /bin/metrics-sqs.rb
|
233
|
+
|
234
|
+
## Usage
|
235
|
+
|
236
|
+
**handler-ses**
|
237
|
+
|
238
|
+
1. Configure [authentication](#authentication)
|
239
|
+
2. Enable the handler in `/etc/sensu/conf.d/handlers/ses.json`:
|
240
|
+
```
|
241
|
+
{
|
242
|
+
"handlers": {
|
243
|
+
"ses": {
|
244
|
+
"type": "pipe",
|
245
|
+
"command": "handler-ses.rb"
|
246
|
+
}
|
247
|
+
}
|
248
|
+
}
|
249
|
+
```
|
250
|
+
3. Configure the handler in `/etc/sensu/conf.d/ses.json`:
|
251
|
+
```
|
252
|
+
{
|
253
|
+
"ses": {
|
254
|
+
"mail_from": "sensu@example.com",
|
255
|
+
"mail_to": "monitor@example.com",
|
256
|
+
"region": "us-east-1",
|
257
|
+
"subscriptions": {
|
258
|
+
"subscription_name": {
|
259
|
+
"mail_to": "teamemail@example.com"
|
260
|
+
}
|
261
|
+
}
|
262
|
+
}
|
263
|
+
}
|
264
|
+
```
|
265
|
+
|
266
|
+
**handler-sns**
|
267
|
+
|
268
|
+
`handler-sns` can be used to send alerts to Email, HTTP endpoints, SMS, or any other [subscription type](http://docs.aws.amazon.com/sns/latest/dg/welcome.html) supported by SNS.
|
269
|
+
|
270
|
+
1. Create an SNS topic and subscription [[Docs]](http://docs.aws.amazon.com/sns/latest/dg/GettingStarted.html)
|
271
|
+
1. Configure [authentication](#authentication)
|
272
|
+
2. Enable the handler in `/etc/sensu/conf.d/handlers/sns.json`:
|
273
|
+
```
|
274
|
+
{
|
275
|
+
"handlers": {
|
276
|
+
"sns": {
|
277
|
+
"type": "pipe",
|
278
|
+
"command": "handler-sns.rb"
|
279
|
+
}
|
280
|
+
}
|
281
|
+
}
|
282
|
+
```
|
283
|
+
3. Configure the handler in `/etc/sensu/conf.d/sns.json`:
|
284
|
+
```
|
285
|
+
{
|
286
|
+
"sns": {
|
287
|
+
"topic_arn": "arn:aws:sns:us-east-1:111111111111:topic",
|
288
|
+
"region": "us-east-1"
|
289
|
+
}
|
290
|
+
}
|
291
|
+
```
|
292
|
+
## Installation
|
293
|
+
|
294
|
+
[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
|
295
|
+
|
296
|
+
Note: In addition to the standard installation requirements the installation of this gem will require compiling the nokogiri gem. Due to this you'll need certain development packages on your system.
|
297
|
+
|
298
|
+
On Ubuntu systems run the following to install build dependencies:
|
299
|
+
|
300
|
+
```
|
301
|
+
sudo apt-get install build-essential libxml2-dev zlib1g-dev
|
302
|
+
```
|
303
|
+
|
304
|
+
On CentOS systems, run the following to install build dependencies:
|
305
|
+
```
|
306
|
+
sudo yum groupinstall -y "Development Tools"
|
307
|
+
sudo yum install -y libxml2-devel zlib-devel
|
308
|
+
```
|
309
|
+
|
310
|
+
If you'd like to avoid compiling nokogiri and other gems on every system where you need to install this plugin collection, please have a look at [the Sensu guide for pre-compiling plugin packages](https://docs.sensu.io/sensu-core/latest/guides/pre-compile-plugins/).
|
311
|
+
|
312
|
+
## Authentication
|
313
|
+
|
314
|
+
AWS credentials are required to execute these checks. Starting with AWS-SDK v2 there are a few
|
315
|
+
methods of passing credentials to the check:
|
316
|
+
|
317
|
+
1. Use a [credential file](http://docs.aws.amazon.com/sdk-for-ruby/v2/developer-guide/setup-config.html#aws-ruby-sdk-credentials-shared). Place the credentials in `~/.aws/credentials`. On Unix-like systems this is going to be `/opt/sensu/.aws/credentials`. Be sure to restrict the file to the `sensu` user.
|
318
|
+
```
|
319
|
+
[default]
|
320
|
+
aws_access_key_id = <access_key>
|
321
|
+
aws_secret_access_key = <secret_access_key>
|
322
|
+
```
|
323
|
+
|
324
|
+
2. Use an [EC2 instance profile](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html). If the checks are executing on an EC2 instance you can give the instance an IAM role and authentication will be handled automatically.
|
325
|
+
|
326
|
+
See the [AWS-SDK docs](http://docs.aws.amazon.com/sdkforruby/api/#Configuration) for more details on
|
327
|
+
credential configuration.
|
328
|
+
|
329
|
+
Some of the checks accept credentials with `aws_access_key` and `aws_secret_access_key` options
|
330
|
+
however this method is deprecated as it is insecure to pass credentials on the command line. Support
|
331
|
+
for these options will be removed in future releases.
|
332
|
+
|
333
|
+
No matter which authentication method is used you should restrict AWS API access to the minimum required to run the checks. In general this is done by limiting the sensu IAM user/role to the necessary `Describe` calls for the services being checked.
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-alb-target-group-health
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin checks the health of Application Load Balancer target groups
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain-text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: aws-sdk
|
16
|
+
# gem: sensu-plugin
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
# Check all target groups in a region
|
20
|
+
# check-alb-target-group-health.rb -r region
|
21
|
+
#
|
22
|
+
# Check a single target group in a region
|
23
|
+
# check-alb-target-group-health.rb -r region -t target-group
|
24
|
+
#
|
25
|
+
# Check multiple target groups in a region
|
26
|
+
# check-alb-target-group-health.rb -r region -t target-group-a,target-group-b
|
27
|
+
#
|
28
|
+
# LICENSE:
|
29
|
+
# Copyright 2017 Eric Heydrick <eheydrick@gmail.com>
|
30
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
31
|
+
# for details.
|
32
|
+
|
33
|
+
require 'aws-sdk'
|
34
|
+
require 'sensu-plugin/check/cli'
|
35
|
+
require 'sensu-plugins-aws'
|
36
|
+
|
37
|
+
class CheckALBTargetGroupHealth < Sensu::Plugin::Check::CLI
|
38
|
+
include Common
|
39
|
+
|
40
|
+
option :target_group,
|
41
|
+
short: '-t',
|
42
|
+
long: '--target-group TARGET_GROUP',
|
43
|
+
description: 'The ALB target group(s) to check. Separate multiple target groups with commas'
|
44
|
+
|
45
|
+
option :aws_region,
|
46
|
+
short: '-r AWS_REGION',
|
47
|
+
long: '--aws-region REGION',
|
48
|
+
description: 'AWS Region (defaults to us-east-1).',
|
49
|
+
default: 'us-east-1'
|
50
|
+
|
51
|
+
option :crit,
|
52
|
+
short: '-c',
|
53
|
+
long: '--crit',
|
54
|
+
description: 'Critical instead of warn when unhealthy targets are found',
|
55
|
+
boolean: true,
|
56
|
+
default: false
|
57
|
+
|
58
|
+
def alb
|
59
|
+
@alb ||= Aws::ElasticLoadBalancingV2::Client.new
|
60
|
+
end
|
61
|
+
|
62
|
+
def unhealthy_target_groups
|
63
|
+
unhealthy_groups = {}
|
64
|
+
|
65
|
+
target_groups_to_check = config[:target_group].split(',') if config[:target_group]
|
66
|
+
target_groups = alb.describe_target_groups(names: target_groups_to_check).target_groups
|
67
|
+
|
68
|
+
target_groups.each do |target_group|
|
69
|
+
health = alb.describe_target_health(target_group_arn: target_group.target_group_arn)
|
70
|
+
unhealthy_targets = health.target_health_descriptions.select { |t| t.target_health.state == 'unhealthy' }.map { |t| t.target.id }
|
71
|
+
healthy_targets = health.target_health_descriptions.select { |t| t.target_health.state == 'healthy' }.map { |t| t.target.id }
|
72
|
+
if !unhealthy_targets.empty? || healthy_targets.empty?
|
73
|
+
unhealthy_groups[target_group.target_group_name] = {
|
74
|
+
unhealthy_targets: unhealthy_targets,
|
75
|
+
healthy_targets: healthy_targets,
|
76
|
+
total_targets: health.target_health_descriptions.size
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
unhealthy_groups
|
81
|
+
end
|
82
|
+
|
83
|
+
def run
|
84
|
+
unhealthy_groups = unhealthy_target_groups
|
85
|
+
|
86
|
+
if !unhealthy_groups.empty?
|
87
|
+
message = 'Unhealthy ALB target groups: '
|
88
|
+
message += unhealthy_groups.map { |target_group, value| "#{target_group} - #{value[:unhealthy_targets].size}/#{value[:total_targets]} unhealthy targets: {#{value[:unhealthy_targets].join(', ')}}" }.join(', ')
|
89
|
+
message += ' : Healthy ALB target groups: '
|
90
|
+
message += unhealthy_groups.map { |target_group, value| "#{target_group} - #{value[:healthy_targets].size}/#{value[:total_targets]} healthy targets: {#{value[:healthy_targets].join(', ')}}" }.join(', ')
|
91
|
+
if config[:crit]
|
92
|
+
critical message
|
93
|
+
else
|
94
|
+
warning message
|
95
|
+
end
|
96
|
+
else
|
97
|
+
ok 'All ALB target groups are healthy'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|