sensu-plugins-aws 7.0.1 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e9b5f1eb3c12c84948ef04dfdccdfbf88fb8a87
4
- data.tar.gz: cda4f9fef7a375bf9c55ace21b3b8bd006cbda5c
3
+ metadata.gz: 642a5f59535c19e584bf6b5fc030bff2e58bb6e1
4
+ data.tar.gz: a8e1650f5e03e6db3b7cc4a3beab15927b5fe2e0
5
5
  SHA512:
6
- metadata.gz: f8cd56ed479d985a5d112b3f53fed0b19f8d4dd8c4fb0c8f84d0ea7853608c64e379e88f8d1cc0adfc73b8d1e599983f077cdbb8c6632a7160b2242b1e8c5b06
7
- data.tar.gz: d18444784a229eabbeec567ac296181970d7c8243a517a6533840cfe49e6ded4abb761fe276a143711f6502aa321ea7e5bed4c326f98a6bfa72a9436a9652c64
6
+ metadata.gz: 508d9dcc967f89eb6fddfd8f96f70cbd4b7b8d836a4279de77f4d929d72abe9c22ee6ed6d58b43964127570ab736b362bc4f2534565ad4ac79e28d549edcd53d
7
+ data.tar.gz: ee5ae8a6ad649711044044531daa82d7edcfa6a2c1d33220b6bb7eaf6d87959333e1106af923b1fb6fbde68c8bb198d45ff20afa8768d24b8e0737a78732b244
data/CHANGELOG.md CHANGED
@@ -5,13 +5,17 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [7.1.0] - 2017-08-14
9
+ ### Added
10
+ - Add `check-alb-target-group-health.rb` that checks the health of ALB target groups (@eheydrick)
11
+
8
12
  ## [7.0.1] - 2017-08-12
9
13
  ### Fixed
10
14
  - check-cloudwatch-metric.rb, check-cloudwatch-composite-metric.rb: fixed defaults to work (@majormoses)
11
15
  - check-cloudwatch-metric.rb: short option `-n` was conflicting with `no_data_ok` and `namespace` as `check-cloudwatch-composite-metric.rb` uses `-O` I opted for that for consistency (@majormoses)
12
16
 
13
17
  ### Changed
14
- - check-cloudwatch-metric.rb, check-cloudwatch-composite-metric.rb: `self.parse_dimensions` and `dimension_string` were the same in both checks This fix was common mamong both checks so I moved it into the module
18
+ - check-cloudwatch-metric.rb, check-cloudwatch-composite-metric.rb: `self.parse_dimensions` and `dimension_string` were the same in both checks. This fix was common among both checks so I moved it into the module
15
19
 
16
20
  ## [7.0.0] - 2017-08-07
17
21
  ### Breaking Change
@@ -344,7 +348,8 @@ WARNING: This release contains major breaking changes that will impact all user
344
348
  ### Added
345
349
  - initial release
346
350
 
347
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/7.0.1...HEAD
351
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/7.1.0...HEAD
352
+ [7.1.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/7.0.1...7.1.0
348
353
  [7.0.1]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/7.0.0...7.0.1
349
354
  [7.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/6.3.0...7.0.0
350
355
  [6.3.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/6.2.0...6.3.0
data/README.md CHANGED
@@ -8,6 +8,8 @@
8
8
 
9
9
  ## Functionality
10
10
 
11
+ **check-alb-target-group-health.rb**
12
+
11
13
  **check-asg-instances-created.rb**
12
14
 
13
15
  **check-asg-instances-inservice.rb**
@@ -151,6 +153,7 @@
151
153
 
152
154
  ## Files
153
155
 
156
+ * /bin/check-alb-target-group-health.rb
154
157
  * /bin/check-asg-instances-created.rb
155
158
  * /bin/check-autoscaling-cpucredits.rb
156
159
  * /bin/check-asg-instances-inservice.rb
@@ -0,0 +1,96 @@
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
+ unless unhealthy_targets.empty?
72
+ unhealthy_groups[target_group.target_group_name] = {
73
+ unhealthy_targets: unhealthy_targets,
74
+ total_targets: health.target_health_descriptions.size
75
+ }
76
+ end
77
+ end
78
+ unhealthy_groups
79
+ end
80
+
81
+ def run
82
+ unhealthy_groups = unhealthy_target_groups
83
+
84
+ if !unhealthy_groups.empty?
85
+ message = 'Unhealthy ALB target groups: '
86
+ message += unhealthy_groups.map { |target_group, value| "#{target_group} - #{value[:unhealthy_targets].size}/#{value[:total_targets]} unhealthy targets: {#{value[:unhealthy_targets].join(', ')}}" }.join(', ')
87
+ if config[:crit]
88
+ critical message
89
+ else
90
+ warning message
91
+ end
92
+ else
93
+ ok 'All ALB target groups are healthy'
94
+ end
95
+ end
96
+ end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsAWS
2
2
  module Version
3
3
  MAJOR = 7
4
- MINOR = 0
5
- PATCH = 1
4
+ MINOR = 1
5
+ PATCH = 0
6
6
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.1
4
+ version: 7.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-12 00:00:00.000000000 Z
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -256,6 +256,7 @@ description: |-
256
256
  for EC2, SES, and SNS.
257
257
  email: "<sensu-users@googlegroups.com>"
258
258
  executables:
259
+ - check-alb-target-group-health.rb
259
260
  - check-asg-instances-created.rb
260
261
  - check-asg-instances-inservice.rb
261
262
  - check-autoscaling-cpucredits.rb
@@ -337,6 +338,7 @@ files:
337
338
  - CHANGELOG.md
338
339
  - LICENSE
339
340
  - README.md
341
+ - bin/check-alb-target-group-health.rb
340
342
  - bin/check-asg-instances-created.rb
341
343
  - bin/check-asg-instances-inservice.rb
342
344
  - bin/check-autoscaling-cpucredits.rb