sensu-plugins-aws-boutetnico 1.1.1 → 1.2.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
  SHA256:
3
- metadata.gz: 14aefd0ae3cc72aa7dbd592f227c1643b624415ac69268267502c25c913f0289
4
- data.tar.gz: 7d2436a38fda39835d0d3b763f4d830c0cede2888ff2a78d768230ffa68f89aa
3
+ metadata.gz: b2a10855b93b31564af58f86c27f72de712191c5f037df52dc742538acfed984
4
+ data.tar.gz: 6b5a92561b5ac979f06cd1cdacc97593a1e9838c3f508fd2c8f20908d4b67d0b
5
5
  SHA512:
6
- metadata.gz: a05ad94ff9da240670b27aad97a697a4cce3d7cce48a4f88d7fb41dcd96906b5f10010bf352916214eb7fc41973c7a295be203313480ba38e79e1d47c1784a86
7
- data.tar.gz: 14536556c223a3cd93a83a9c63a164888a6439697ba1f7b776c7130d090a1958f3324a8cade4293387b1109a6fa6306ccd6952a99e65cc71a3cd422bd5692745
6
+ metadata.gz: 3e59d8f558e7b293eef240679a68f7681c1a9c7ed443a3183bffa1347dd47d9bb4498b4d42f25ae58eca29f0a3ebdefd3b345b4742db72242c051e822021c44e
7
+ data.tar.gz: 1958f736c2e8846f0d2082f7246bce9d149e24c9b4cc57bfe38c3446422a4c0249a470245162567c92c920db767afa6524397354643649af44f64302a0bd80d5
@@ -25,10 +25,17 @@
25
25
  # Check multiple target groups in a region
26
26
  # check-alb-target-group-health.rb -r region -t target-group-a,target-group-b
27
27
  #
28
+ # Check multiple target groups starting with a prefix in name
29
+ # check-alb-target-group-health.rb -r region -p prod
30
+ #
31
+ # Check multiple target groups starting with a prefix in name and excluding by name
32
+ # check-alb-target-group-health.rb -r region -p prod -e staging,dev
33
+ #
28
34
  # LICENSE:
29
35
  # Copyright 2017 Eric Heydrick <eheydrick@gmail.com>
30
36
  # Released under the same terms as Sensu (the MIT license); see LICENSE
31
37
  # for details.
38
+ # Modified by Nicolas Boutet <amd3002@gmail.com>
32
39
 
33
40
  require 'aws-sdk'
34
41
  require 'sensu-plugin/check/cli'
@@ -55,6 +62,19 @@ class CheckALBTargetGroupHealth < Sensu::Plugin::Check::CLI
55
62
  boolean: true,
56
63
  default: false
57
64
 
65
+ option :name_prefix,
66
+ description: 'Target group name prefix',
67
+ short: '-p NAME_PREFIX',
68
+ long: '--name-prefix NAME_PREFIX',
69
+ default: ''
70
+
71
+ option :exclude,
72
+ description: 'Exclude target groups by name',
73
+ short: '-e EXCLUDE',
74
+ long: '--exclude',
75
+ proc: proc { |a| a.split(',') },
76
+ default: []
77
+
58
78
  def alb
59
79
  @alb ||= Aws::ElasticLoadBalancingV2::Client.new
60
80
  end
@@ -65,6 +85,14 @@ class CheckALBTargetGroupHealth < Sensu::Plugin::Check::CLI
65
85
  target_groups_to_check = config[:target_group].split(',') if config[:target_group]
66
86
  target_groups = alb.describe_target_groups(names: target_groups_to_check).target_groups
67
87
 
88
+ unless config[:name_prefix].empty?
89
+ target_groups.keep_if { |target_group| target_group.target_group_name.start_with?(config[:name_prefix]) }
90
+ end
91
+
92
+ config[:exclude].each do |x|
93
+ target_groups.delete_if { |target_group| target_group.target_group_name.match(x) }
94
+ end
95
+
68
96
  target_groups.each do |target_group|
69
97
  health = alb.describe_target_health(target_group_arn: target_group.target_group_arn)
70
98
  unhealthy_targets = health.target_health_descriptions.select { |t| t.target_health.state == 'unhealthy' }.map { |t| t.target.id }
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsAWS
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 1
5
- PATCH = 1
4
+ MINOR = 2
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-boutetnico
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.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: 2020-03-24 00:00:00.000000000 Z
11
+ date: 2020-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin