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
@@ -0,0 +1,154 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-instance-events
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin looks up all instances in an account and alerts if one or more have a scheduled
|
7
|
+
# event (reboot, retirement, etc)
|
8
|
+
#
|
9
|
+
# OUTPUT:
|
10
|
+
# plain-text
|
11
|
+
#
|
12
|
+
# PLATFORMS:
|
13
|
+
# Linux
|
14
|
+
#
|
15
|
+
# DEPENDENCIES:
|
16
|
+
# gem: aws-sdk
|
17
|
+
# gem: sensu-plugin
|
18
|
+
#
|
19
|
+
# USAGE:
|
20
|
+
# #YELLOW
|
21
|
+
#
|
22
|
+
# NOTES:
|
23
|
+
#
|
24
|
+
# LICENSE:
|
25
|
+
# Copyright (c) 2014, Tim Smith, tsmith@chef.io
|
26
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
27
|
+
# for details.
|
28
|
+
#
|
29
|
+
|
30
|
+
require 'sensu-plugin/check/cli'
|
31
|
+
require 'aws-sdk'
|
32
|
+
|
33
|
+
class CheckInstanceEvents < Sensu::Plugin::Check::CLI
|
34
|
+
option :aws_access_key,
|
35
|
+
short: '-a AWS_ACCESS_KEY',
|
36
|
+
long: '--aws-access-key AWS_ACCESS_KEY',
|
37
|
+
description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
|
38
|
+
default: ENV['AWS_ACCESS_KEY']
|
39
|
+
|
40
|
+
option :aws_secret_access_key,
|
41
|
+
short: '-k AWS_SECRET_KEY',
|
42
|
+
long: '--aws-secret-access-key AWS_SECRET_KEY',
|
43
|
+
description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
|
44
|
+
default: ENV['AWS_SECRET_KEY']
|
45
|
+
|
46
|
+
option :aws_region,
|
47
|
+
short: '-r AWS_REGION',
|
48
|
+
long: '--aws-region REGION',
|
49
|
+
description: 'AWS Region (defaults to us-east-1).',
|
50
|
+
default: 'us-east-1'
|
51
|
+
|
52
|
+
option :use_iam_role,
|
53
|
+
short: '-u',
|
54
|
+
long: '--use-iam',
|
55
|
+
description: 'Use IAM role authenticiation. Instance must have IAM role assigned for this to work'
|
56
|
+
|
57
|
+
option :instance_id,
|
58
|
+
short: '-i INSTANCE_IDS',
|
59
|
+
long: '--instances INSTANCES_IDS',
|
60
|
+
description: 'Comma separated list of instances ids to check. Defaults to all instances in the region',
|
61
|
+
proc: proc { |a| a.split(',') },
|
62
|
+
default: []
|
63
|
+
|
64
|
+
option :include_name,
|
65
|
+
short: '-n',
|
66
|
+
long: '--include-name',
|
67
|
+
description: "Includes any offending instance's 'Name' tag in the check output",
|
68
|
+
default: false
|
69
|
+
|
70
|
+
def aws_config
|
71
|
+
{ access_key_id: config[:aws_access_key],
|
72
|
+
secret_access_key: config[:aws_secret_access_key],
|
73
|
+
region: config[:aws_region] }
|
74
|
+
end
|
75
|
+
|
76
|
+
def ec2_regions
|
77
|
+
Aws.partition('aws').regions.map(&:name)
|
78
|
+
end
|
79
|
+
|
80
|
+
def run
|
81
|
+
event_instances = []
|
82
|
+
aws_config = {}
|
83
|
+
|
84
|
+
aws_regions = ec2_regions
|
85
|
+
|
86
|
+
unless config[:aws_region].casecmp('all').zero?
|
87
|
+
if aws_regions.include? config[:aws_region]
|
88
|
+
aws_regions.clear.push(config[:aws_region])
|
89
|
+
else
|
90
|
+
critical 'Invalid region specified!'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
if config[:use_iam_role].nil?
|
95
|
+
aws_config[:access_key_id] = config[:aws_access_key]
|
96
|
+
aws_config[:secret_access_key] = config[:aws_secret_access_key]
|
97
|
+
end
|
98
|
+
|
99
|
+
# TODO: come back and refactor this
|
100
|
+
aws_regions.each do |r| # Iterate each possible region # rubocop:disable Metrics/BlockLength)
|
101
|
+
ec2 = Aws::EC2::Client.new(aws_config.merge!(region: r))
|
102
|
+
begin
|
103
|
+
describe_instance_options = {}
|
104
|
+
if config[:instance_id].any?
|
105
|
+
describe_instance_options = describe_instance_options.merge(instance_ids: config[:instance_id])
|
106
|
+
end
|
107
|
+
|
108
|
+
ec2.describe_instance_status(describe_instance_options).instance_statuses.each do |i|
|
109
|
+
next if i[:events].empty?
|
110
|
+
|
111
|
+
# Exclude completed reboots since the events API appearently returns these even after they have been completed:
|
112
|
+
# Example:
|
113
|
+
# "events_set": [
|
114
|
+
# {
|
115
|
+
# "code": "system-reboot",
|
116
|
+
# "description": "[Completed] Scheduled reboot",
|
117
|
+
# "not_before": "2015-01-05 12:00:00 UTC",
|
118
|
+
# "not_after": "2015-01-05 18:00:00 UTC"
|
119
|
+
# }
|
120
|
+
# ]
|
121
|
+
useful_events =
|
122
|
+
i[:events].reject { |x| (x[:code] =~ /system-reboot|instance-reboot|instance-stop|system-maintenance/) && (x[:description] =~ /\[Completed\]|\[Canceled\]/) }
|
123
|
+
|
124
|
+
unless useful_events.empty?
|
125
|
+
name = ''
|
126
|
+
if config[:include_name]
|
127
|
+
begin
|
128
|
+
instance_desc = ec2.describe_instances(instance_ids: [i[:instance_id]])
|
129
|
+
name_tag = instance_desc.reservations[0].instances[0].tags.find { |tag| tag[:key] == 'Name' }
|
130
|
+
name = name_tag.nil? ? '' : name_tag.value
|
131
|
+
rescue StandardError => e
|
132
|
+
puts "Issue getting instance details for #{i[:instance_id]} (#{r}). Exception = #{e}"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
event_instances << if name.empty?
|
137
|
+
"#{i[:instance_id]} (#{r}) (#{i[:events][0][:code]}) #{i[:events][0][:description]}"
|
138
|
+
else
|
139
|
+
"#{name} (#{i[:instance_id]} #{r}) (#{i[:events][0][:code]}) #{i[:events][0][:description]}"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
rescue StandardError => e
|
144
|
+
unknown "An error occurred processing AWS EC2 API (#{r}): #{e.message}"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
if event_instances.count > 0
|
149
|
+
critical("#{event_instances.count} instance#{event_instances.count > 1 ? 's have' : ' has'} upcoming scheduled events: #{event_instances.join(',')}")
|
150
|
+
else
|
151
|
+
ok
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-instance-health
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin looks up all instances in an account and checks event data, system status
|
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
|
+
# #YELLOW
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
#
|
23
|
+
# LICENSE:
|
24
|
+
# Shane Starcher
|
25
|
+
# Copyright (c) 2016
|
26
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
27
|
+
# for details.
|
28
|
+
#
|
29
|
+
|
30
|
+
require 'sensu-plugins-aws'
|
31
|
+
require 'sensu-plugin/check/cli'
|
32
|
+
require 'aws-sdk'
|
33
|
+
|
34
|
+
class CheckInstanceEvents < Sensu::Plugin::Check::CLI
|
35
|
+
include Common
|
36
|
+
|
37
|
+
option :aws_region,
|
38
|
+
short: '-r AWS_REGION',
|
39
|
+
long: '--aws-region REGION',
|
40
|
+
description: 'AWS Region (defaults to us-east-1).',
|
41
|
+
default: 'us-east-1'
|
42
|
+
option :filter,
|
43
|
+
short: '-f FILTER',
|
44
|
+
long: '--filter FILTER',
|
45
|
+
description: 'String representation of the filter to apply',
|
46
|
+
default: '{}'
|
47
|
+
|
48
|
+
def gather_events(events)
|
49
|
+
useful_events = events.reject { |x| (x[:code] =~ /system-reboot|instance-stop|system-maintenance/) || (x[:description] =~ /\[Completed\]|\[Canceled\]/) }
|
50
|
+
!useful_events.empty?
|
51
|
+
end
|
52
|
+
|
53
|
+
def gather_status(status_checks)
|
54
|
+
['impaired', 'insufficient-data'].include? status_checks.status
|
55
|
+
end
|
56
|
+
|
57
|
+
def run
|
58
|
+
filter = Filter.parse(config[:filter])
|
59
|
+
options = if filter.empty?
|
60
|
+
{}
|
61
|
+
else
|
62
|
+
{ filters: filter }
|
63
|
+
end
|
64
|
+
|
65
|
+
messages = []
|
66
|
+
|
67
|
+
ec2 = Aws::EC2::Client.new
|
68
|
+
instance_ids = []
|
69
|
+
|
70
|
+
instances = ec2.describe_instances(options)
|
71
|
+
instances.reservations.each do |r|
|
72
|
+
r.instances.each do |i|
|
73
|
+
instance_ids.push(i[:instance_id])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
begin
|
78
|
+
resp = []
|
79
|
+
instance_ids.each_slice(100) do |batch|
|
80
|
+
resp << ec2.describe_instance_status(instance_ids: batch)
|
81
|
+
end
|
82
|
+
resp.each do |r|
|
83
|
+
r.instance_statuses.each do |item|
|
84
|
+
id = item.instance_id
|
85
|
+
if gather_events(item.events)
|
86
|
+
messages << "#{id} has unscheduled events"
|
87
|
+
end
|
88
|
+
|
89
|
+
if gather_status(item.system_status)
|
90
|
+
messages << "#{id} has failed system status checks"
|
91
|
+
end
|
92
|
+
|
93
|
+
if gather_status(item.instance_status)
|
94
|
+
messages << "#{id} has failed instance status checks"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
rescue StandardError => e
|
99
|
+
unknown "An error occurred processing AWS EC2 API: #{e.message}"
|
100
|
+
end
|
101
|
+
|
102
|
+
if messages.count > 0
|
103
|
+
critical("#{messages.count} instances #{messages.count > 1 ? 'have' : 'has'}: #{messages.join(',')}")
|
104
|
+
else
|
105
|
+
ok
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-instance-reachability
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin looks up all instances from a filter set and pings
|
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
|
+
# #YELLOW
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
#
|
23
|
+
# LICENSE:
|
24
|
+
# Copyright (c) 2014, Leon Gibat, brendan.gibat@gmail.com
|
25
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
26
|
+
# for details.
|
27
|
+
#
|
28
|
+
|
29
|
+
require 'sensu-plugin/check/cli'
|
30
|
+
require 'aws-sdk'
|
31
|
+
require 'sensu-plugins-aws'
|
32
|
+
|
33
|
+
class CheckInstanceReachability < Sensu::Plugin::Check::CLI
|
34
|
+
include Common
|
35
|
+
include Filter
|
36
|
+
|
37
|
+
option :aws_region,
|
38
|
+
short: '-r AWS_REGION',
|
39
|
+
long: '--aws-region REGION',
|
40
|
+
description: 'AWS Region (defaults to us-east-1).',
|
41
|
+
default: 'us-east-1'
|
42
|
+
|
43
|
+
option :filter,
|
44
|
+
short: '-f FILTER',
|
45
|
+
long: '--filter FILTER',
|
46
|
+
description: 'String representation of the filter to apply',
|
47
|
+
default: '{}'
|
48
|
+
|
49
|
+
option :timeout,
|
50
|
+
description: 'Ping timeout in seconds',
|
51
|
+
short: '-t TIMEOUT',
|
52
|
+
long: '--timeout TIMEOUT',
|
53
|
+
default: 5,
|
54
|
+
proc: proc(&:to_i)
|
55
|
+
|
56
|
+
option :count,
|
57
|
+
description: 'Ping count',
|
58
|
+
short: '-c COUNT',
|
59
|
+
long: '--count COUNT',
|
60
|
+
default: 1,
|
61
|
+
proc: proc(&:to_i)
|
62
|
+
|
63
|
+
option :critical_response,
|
64
|
+
description: 'Flag if the response should error on failures',
|
65
|
+
short: '-r',
|
66
|
+
long: '--critical-response',
|
67
|
+
boolean: true,
|
68
|
+
default: false
|
69
|
+
|
70
|
+
def run
|
71
|
+
begin
|
72
|
+
aws_config
|
73
|
+
client = Aws::EC2::Client.new
|
74
|
+
|
75
|
+
filter = Filter.parse(config[:filter])
|
76
|
+
|
77
|
+
options = { filters: filter }
|
78
|
+
|
79
|
+
errors = []
|
80
|
+
instance_ids = []
|
81
|
+
data = client.describe_instances(options)
|
82
|
+
|
83
|
+
data[:reservations].each do |res|
|
84
|
+
res[:instances].each do |i|
|
85
|
+
instance_ids << i[:instance_id]
|
86
|
+
`ping -c #{config[:count]} -W #{config[:timeout]} #{i[:private_ip_address]}`
|
87
|
+
if $CHILD_STATUS.to_i > 0
|
88
|
+
errors << "Could not reach #{i[:instance_id]}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
rescue StandardError => e
|
93
|
+
puts "Error: exception: #{e}"
|
94
|
+
critical
|
95
|
+
end
|
96
|
+
if errors.empty?
|
97
|
+
ok "Instances checked: #{instance_ids.join(',')}"
|
98
|
+
else
|
99
|
+
message = errors.join(',')
|
100
|
+
if config[:critical_response]
|
101
|
+
critical message
|
102
|
+
else
|
103
|
+
warning message
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-instances-count
|
4
|
+
#
|
5
|
+
#
|
6
|
+
# DESCRIPTION:
|
7
|
+
# This plugin checks the instances count for a specific auto scale group ( ASG ).
|
8
|
+
# Goal is to allow you to monitor that your ASG isnt out of control
|
9
|
+
#
|
10
|
+
# OUTPUT:
|
11
|
+
# plain-text
|
12
|
+
#
|
13
|
+
# PLATFORMS:
|
14
|
+
# Linux
|
15
|
+
#
|
16
|
+
# DEPENDENCIES:
|
17
|
+
# gem: aws-sdk
|
18
|
+
# gem: sensu-plugin
|
19
|
+
#
|
20
|
+
# USAGE:
|
21
|
+
# check-instances-count.rb --warn 15 --crit 25 --groupname logstash-instances-auto
|
22
|
+
#
|
23
|
+
#
|
24
|
+
#
|
25
|
+
# NOTES:
|
26
|
+
#
|
27
|
+
# LICENSE:
|
28
|
+
# Copyright (c) 2015, Kevin Bond
|
29
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
30
|
+
# for details.
|
31
|
+
#
|
32
|
+
|
33
|
+
require 'sensu-plugins-aws'
|
34
|
+
require 'sensu-plugin/check/cli'
|
35
|
+
require 'aws-sdk'
|
36
|
+
|
37
|
+
# Class to check the instance count
|
38
|
+
class CheckInstanceCount < Sensu::Plugin::Check::CLI
|
39
|
+
include Common
|
40
|
+
|
41
|
+
option :groupname,
|
42
|
+
description: 'Name of the AutoScaling group',
|
43
|
+
short: '-g GROUP_NAME',
|
44
|
+
long: '--groupname GROUP_NAME',
|
45
|
+
required: true
|
46
|
+
|
47
|
+
option :aws_region,
|
48
|
+
short: '-r AWS_REGION',
|
49
|
+
long: '--aws-region REGION',
|
50
|
+
description: 'AWS Region (such as us-east-1).',
|
51
|
+
default: 'us-east-1'
|
52
|
+
|
53
|
+
option :warn,
|
54
|
+
short: '-w COUNT',
|
55
|
+
long: '--warn COUNT',
|
56
|
+
proc: proc(&:to_i),
|
57
|
+
default: 15
|
58
|
+
|
59
|
+
option :crit,
|
60
|
+
short: '-c COUNT',
|
61
|
+
long: '--crit COUNT',
|
62
|
+
proc: proc(&:to_i),
|
63
|
+
default: 25
|
64
|
+
|
65
|
+
def instance_count
|
66
|
+
client = Aws::AutoScaling::Client.new
|
67
|
+
resp = client.describe_auto_scaling_groups(
|
68
|
+
auto_scaling_group_names: [config[:groupname]]
|
69
|
+
).to_h
|
70
|
+
instances = []
|
71
|
+
resp[:auto_scaling_groups].each do |g|
|
72
|
+
g[:instances].each do |i|
|
73
|
+
if i[:lifecycle_state] == 'InService' && i[:health_status] == 'Healthy'
|
74
|
+
instances << i[:instance_id]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
instances.length
|
79
|
+
rescue StandardError => e
|
80
|
+
critical "There was an error reaching AWS - #{e.message}"
|
81
|
+
end
|
82
|
+
|
83
|
+
def run
|
84
|
+
count = instance_count
|
85
|
+
msg_prefix = "#{count} instances running for ASG [ #{config[:groupname]} ]"
|
86
|
+
if count >= config[:crit]
|
87
|
+
critical "#{msg_prefix} - critical threshold #{config[:crit]}"
|
88
|
+
elsif count >= config[:warn]
|
89
|
+
warning "#{msg_prefix} - warning threshold #{config[:warn]}, critical threshold #{config[:crit]}"
|
90
|
+
else
|
91
|
+
ok msg_prefix
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|