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,89 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-ses-limit
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Gets your SES sending limit and issues a warn and critical based on percentages
|
7
|
+
# you supply for your daily sending limit
|
8
|
+
# Checks how close you are getting in percentages to your 24 hour ses sending limit
|
9
|
+
#
|
10
|
+
# OUTPUT:
|
11
|
+
# plain-text
|
12
|
+
#
|
13
|
+
# PLATFORMS:
|
14
|
+
# Linux
|
15
|
+
#
|
16
|
+
# DEPENDENCIES:
|
17
|
+
# gem: aws-sdk
|
18
|
+
# gem: sensu-plugin
|
19
|
+
# gem: sensu-plugins-aws
|
20
|
+
#
|
21
|
+
# USAGE:
|
22
|
+
# #YELLOW
|
23
|
+
#
|
24
|
+
# NOTES:
|
25
|
+
#
|
26
|
+
# LICENSE:
|
27
|
+
# Copyright (c) 2014, Joel <jjshoe@gmail.com>
|
28
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
29
|
+
# for details.
|
30
|
+
#
|
31
|
+
|
32
|
+
require 'sensu-plugin/check/cli'
|
33
|
+
require 'sensu-plugins-aws'
|
34
|
+
require 'aws-sdk'
|
35
|
+
|
36
|
+
class CheckSESLimit < Sensu::Plugin::Check::CLI
|
37
|
+
include Common
|
38
|
+
option :aws_access_key,
|
39
|
+
short: '-a AWS_ACCESS_KEY',
|
40
|
+
long: '--aws-access-key AWS_ACCESS_KEY',
|
41
|
+
description: 'AWS Access Key ID.'
|
42
|
+
|
43
|
+
option :aws_secret_access_key,
|
44
|
+
short: '-k AWS_SECRET_KEY',
|
45
|
+
long: '--aws-secret-access-key AWS_SECRET_KEY',
|
46
|
+
description: 'AWS Secret Access Key.'
|
47
|
+
|
48
|
+
option :aws_region,
|
49
|
+
short: '-r AWS_REGION',
|
50
|
+
long: '--aws-region REGION',
|
51
|
+
description: 'AWS Region (defaults to us-east-1).',
|
52
|
+
default: 'us-east-1'
|
53
|
+
|
54
|
+
option :warn_percent,
|
55
|
+
short: '-W WARN_PERCENT',
|
56
|
+
long: '--warn_perc WARN_PERCENT',
|
57
|
+
description: 'Warn when the percentage of mail sent is at or above this number',
|
58
|
+
default: 75,
|
59
|
+
proc: proc(&:to_i)
|
60
|
+
|
61
|
+
option :crit_percent,
|
62
|
+
short: '-C CRIT_PERCENT',
|
63
|
+
long: '--crit_perc CRIT_PERCENT',
|
64
|
+
description: 'Critical when the percentage of mail sent is at or above this number',
|
65
|
+
default: 90,
|
66
|
+
proc: proc(&:to_i)
|
67
|
+
|
68
|
+
def run
|
69
|
+
begin
|
70
|
+
ses = Aws::SES::Client.new
|
71
|
+
response = ses.get_send_quota
|
72
|
+
rescue StandardError => e
|
73
|
+
unknown "An issue occured while communicating with the AWS SES API: #{e.message}"
|
74
|
+
end
|
75
|
+
|
76
|
+
unknown 'Empty response from AWS SES API' if response.empty? # Can this happen?
|
77
|
+
|
78
|
+
percent = ((response.sent_last_24_hours.to_f / response.max_24_hour_send.to_f) * 100).to_i
|
79
|
+
message = "SES sending limit is at #{percent}%"
|
80
|
+
|
81
|
+
if config[:crit_percent] > 0 && config[:crit_percent] <= percent
|
82
|
+
critical message
|
83
|
+
elsif config[:warn_percent] > 0 && config[:warn_percent] <= percent
|
84
|
+
warning message
|
85
|
+
else
|
86
|
+
ok message
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-ses-statistics
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Alerts on threshold values for SES statistics
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain-text
|
10
|
+
#
|
11
|
+
# DEPENDENCIES:
|
12
|
+
# gem: aws-sdk
|
13
|
+
# gem: sensu-plugin
|
14
|
+
#
|
15
|
+
# USAGE:
|
16
|
+
# check-ses-statistics.rb -r us-west-2 -b 1 -B 2 -c 5 -C 10 -j 10 -J 20
|
17
|
+
#
|
18
|
+
# This will alert on bounces, complaints, rejects or delivery attempts
|
19
|
+
# if they equal or exceed (>=) threshold values,
|
20
|
+
#
|
21
|
+
# It will alert on delivery attempts if they fall below (<) threshold values.
|
22
|
+
#
|
23
|
+
# NOTES:
|
24
|
+
#
|
25
|
+
# LICENSE:
|
26
|
+
# Brandon Smith <freedom@reardencode.com>
|
27
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
28
|
+
# for details.
|
29
|
+
|
30
|
+
require 'sensu-plugins-aws'
|
31
|
+
require 'sensu-plugin/check/cli'
|
32
|
+
require 'aws-sdk'
|
33
|
+
|
34
|
+
class CheckSesStatistics < 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
|
+
|
43
|
+
option :low_delivery_warn,
|
44
|
+
short: '-l COUNT',
|
45
|
+
long: '--low_delivery_warn',
|
46
|
+
description: 'Number of delivery attempts to warn below.',
|
47
|
+
default: 0,
|
48
|
+
proc: proc(&:to_i)
|
49
|
+
|
50
|
+
option :low_delivery_crit,
|
51
|
+
short: '-L COUNT',
|
52
|
+
long: '--low_delivery_crit',
|
53
|
+
description: 'Number of delivery attempts to alert below.',
|
54
|
+
default: 0,
|
55
|
+
proc: proc(&:to_i)
|
56
|
+
|
57
|
+
option :delivery_warn,
|
58
|
+
short: '-d COUNT',
|
59
|
+
long: '--delivery_warn',
|
60
|
+
description: 'Number of delivery attempts to warn above.',
|
61
|
+
default: 0,
|
62
|
+
proc: proc(&:to_i)
|
63
|
+
|
64
|
+
option :delivery_crit,
|
65
|
+
short: '-D COUNT',
|
66
|
+
long: '--delivery_crit',
|
67
|
+
description: 'Number of delivery attempts to alert above.',
|
68
|
+
default: 0,
|
69
|
+
proc: proc(&:to_i)
|
70
|
+
|
71
|
+
option :complaint_warn,
|
72
|
+
short: '-c COUNT',
|
73
|
+
long: '--complaint_warn',
|
74
|
+
description: 'Number of complaints to warn above.',
|
75
|
+
default: 0,
|
76
|
+
proc: proc(&:to_i)
|
77
|
+
|
78
|
+
option :complaint_crit,
|
79
|
+
short: '-C COUNT',
|
80
|
+
long: '--complaint_crit',
|
81
|
+
description: 'Number of complaints to alert above.',
|
82
|
+
default: 0,
|
83
|
+
proc: proc(&:to_i)
|
84
|
+
|
85
|
+
option :reject_warn,
|
86
|
+
short: '-j COUNT',
|
87
|
+
long: '--reject_warn',
|
88
|
+
description: 'Number of rejects to warn above.',
|
89
|
+
default: 0,
|
90
|
+
proc: proc(&:to_i)
|
91
|
+
|
92
|
+
option :reject_crit,
|
93
|
+
short: '-J COUNT',
|
94
|
+
long: '--reject_crit',
|
95
|
+
description: 'Number of rejects to alert above.',
|
96
|
+
default: 0,
|
97
|
+
proc: proc(&:to_i)
|
98
|
+
|
99
|
+
option :bounce_warn,
|
100
|
+
short: '-b COUNT',
|
101
|
+
long: '--bounce_warn',
|
102
|
+
description: 'Number of bounces to warn above.',
|
103
|
+
default: 0,
|
104
|
+
proc: proc(&:to_i)
|
105
|
+
|
106
|
+
option :bounce_crit,
|
107
|
+
short: '-B COUNT',
|
108
|
+
long: '--bounce_crit',
|
109
|
+
description: 'Number of bounces to alert above.',
|
110
|
+
default: 0,
|
111
|
+
proc: proc(&:to_i)
|
112
|
+
|
113
|
+
def run
|
114
|
+
ses = Aws::SES::Client.new(aws_config)
|
115
|
+
begin
|
116
|
+
response = ses.get_send_statistics
|
117
|
+
|
118
|
+
unknown 'Empty response from AWS SES API' if response.empty? # Can this happen?
|
119
|
+
unknown 'No data points from AWS SES API' if response.send_data_points.empty?
|
120
|
+
|
121
|
+
data_point = response.send_data_points.sort_by(&:timestamp).last
|
122
|
+
bounces = data_point.bounces
|
123
|
+
rejects = data_point.rejects
|
124
|
+
complaints = data_point.complaints
|
125
|
+
delivery_attempts = data_point.delivery_attempts
|
126
|
+
|
127
|
+
message = "SES stats for #{data_point.timestamp}: "\
|
128
|
+
"#{delivery_attempts} delivery attempts, #{bounces} bounces, #{rejects} rejects, #{complaints} complaints"
|
129
|
+
|
130
|
+
if config[:complaint_crit] > 0 && config[:complaint_crit] <= complaints || \
|
131
|
+
config[:reject_crit] > 0 && config[:reject_crit] <= rejects || \
|
132
|
+
config[:bounce_crit] > 0 && config[:bounce_crit] <= bounces || \
|
133
|
+
config[:low_delivery_crit] > 0 && config[:low_delivery_crit] > bounces || \
|
134
|
+
config[:delivery_crit] > 0 && config[:delivery_crit] <= bounces
|
135
|
+
|
136
|
+
critical message
|
137
|
+
elsif config[:complaint_warn] > 0 && config[:complaint_warn] <= complaints || \
|
138
|
+
config[:reject_warn] > 0 && config[:reject_warn] <= rejects || \
|
139
|
+
config[:bounce_warn] > 0 && config[:bounce_warn] <= bounces || \
|
140
|
+
config[:low_delivery_warn] > 0 && config[:low_delivery_warn] > bounces || \
|
141
|
+
config[:delivery_warn] > 0 && config[:delivery_warn] <= bounces
|
142
|
+
|
143
|
+
warning message
|
144
|
+
else
|
145
|
+
ok message
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-sns-subscriptions
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin checks if topics's subscriptions are not 'PendingConfirmation' state.
|
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-sns-subscriptions.rb --aws-region eu-west-1
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
#
|
23
|
+
# LICENSE:
|
24
|
+
# Copyright (c) 2016, Olivier Bazoud, olivier.bazoud@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 'sensu-plugins-aws'
|
31
|
+
require 'aws-sdk'
|
32
|
+
|
33
|
+
class CheckSNSSubscriptions < Sensu::Plugin::Check::CLI
|
34
|
+
include Common
|
35
|
+
|
36
|
+
option :aws_region,
|
37
|
+
short: '-r AWS_REGION',
|
38
|
+
long: '--aws-region REGION',
|
39
|
+
description: 'AWS Region (defaults to us-east-1).',
|
40
|
+
default: 'us-east-1'
|
41
|
+
|
42
|
+
def run
|
43
|
+
sns = Aws::SNS::Client.new
|
44
|
+
|
45
|
+
subscriptions = sns.list_subscriptions.subscriptions
|
46
|
+
|
47
|
+
pending_confirmations = subscriptions.select { |subscription| subscription.subscription_arn == 'PendingConfirmation' }.map(&:topic_arn)
|
48
|
+
|
49
|
+
critical "#{pending_confirmations.size} pending confirmations (#{pending_confirmations})" unless pending_confirmations.empty?
|
50
|
+
ok
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-sqs-messages
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin checks the number of messages in an Amazon Web Services SQS queue.
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain-text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: aws-sdk-v2
|
16
|
+
# gem: sensu-plugin
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
# check-sqs-messages -q my_queue -w 500 -c 1000
|
20
|
+
# check-sqs-messages -p queue_prefix_ -W 100 -C 50
|
21
|
+
#
|
22
|
+
# NOTES:
|
23
|
+
#
|
24
|
+
# LICENSE:
|
25
|
+
# Copyright (c) 2013, Justin Lambert <jlambert@letsevenup.com>
|
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 'sensu-plugins-aws'
|
32
|
+
require 'aws-sdk'
|
33
|
+
|
34
|
+
#
|
35
|
+
# Check SQS Messages
|
36
|
+
#
|
37
|
+
class SQSMsgs < Sensu::Plugin::Check::CLI
|
38
|
+
include Common
|
39
|
+
|
40
|
+
option :aws_region,
|
41
|
+
short: '-r AWS_REGION',
|
42
|
+
long: '--aws-region REGION',
|
43
|
+
description: 'AWS Region (defaults to us-east-1).',
|
44
|
+
default: 'us-east-1'
|
45
|
+
|
46
|
+
option :queues,
|
47
|
+
short: '-q SQS_QUEUE',
|
48
|
+
long: '--queue SQS_QUEUE',
|
49
|
+
description: 'A comma seperated list of the SQS queue(s) you want to check the number of messages for',
|
50
|
+
default: [],
|
51
|
+
proc: proc { |q| q.split(',') }
|
52
|
+
|
53
|
+
option :exclude_queues,
|
54
|
+
short: '-Q SQS_QUEUES',
|
55
|
+
long: '--exclude-queues SQS_QUEUE',
|
56
|
+
description: 'A comma separated list of the SQS queue(s) to exclude, if using --prefix',
|
57
|
+
default: [],
|
58
|
+
proc: proc { |q| q.split(',') }
|
59
|
+
|
60
|
+
option :prefix,
|
61
|
+
short: '-p PREFIX',
|
62
|
+
long: '--prefix PREFIX',
|
63
|
+
description: 'The prefix of the queues you want to check the number of messages for',
|
64
|
+
default: ''
|
65
|
+
|
66
|
+
option :metric,
|
67
|
+
short: '-m METRIC',
|
68
|
+
long: '--metric METRIC',
|
69
|
+
description: 'The metric of the queues you want to check the number of messages for',
|
70
|
+
default: 'ApproximateNumberOfMessages'
|
71
|
+
|
72
|
+
option :warn_over,
|
73
|
+
short: '-w WARN_OVER',
|
74
|
+
long: '--warnnum WARN_OVER',
|
75
|
+
description: 'Number of messages in the queue considered to be a warning',
|
76
|
+
default: -1,
|
77
|
+
proc: proc(&:to_i)
|
78
|
+
|
79
|
+
option :crit_over,
|
80
|
+
short: '-c CRIT_OVER',
|
81
|
+
long: '--critnum CRIT_OVER',
|
82
|
+
description: 'Number of messages in the queue considered to be critical',
|
83
|
+
default: -1,
|
84
|
+
proc: proc(&:to_i)
|
85
|
+
|
86
|
+
option :warn_under,
|
87
|
+
short: '-W WARN_UNDER',
|
88
|
+
long: '--warnunder WARN_UNDER',
|
89
|
+
description: 'Minimum number of messages in the queue considered to be a warning',
|
90
|
+
default: -1,
|
91
|
+
proc: proc(&:to_i)
|
92
|
+
|
93
|
+
option :crit_under,
|
94
|
+
short: '-C CRIT_UNDER',
|
95
|
+
long: '--critunder CRIT_UNDER',
|
96
|
+
description: 'Minimum number of messages in the queue considered to be critical',
|
97
|
+
default: -1,
|
98
|
+
proc: proc(&:to_i)
|
99
|
+
|
100
|
+
def aws_config
|
101
|
+
{ access_key_id: config[:aws_access_key],
|
102
|
+
secret_access_key: config[:aws_secret_access_key],
|
103
|
+
region: config[:aws_region] }
|
104
|
+
end
|
105
|
+
|
106
|
+
def run
|
107
|
+
Aws.config.update(aws_config)
|
108
|
+
sqs = Aws::SQS::Resource.new
|
109
|
+
|
110
|
+
if config[:prefix].empty?
|
111
|
+
if config[:queues].empty?
|
112
|
+
critical 'Error, either QUEUE or PREFIX must be specified'
|
113
|
+
end
|
114
|
+
|
115
|
+
warnings = []
|
116
|
+
crits = []
|
117
|
+
passing = []
|
118
|
+
queues = config[:queues]
|
119
|
+
queues.each do |q|
|
120
|
+
url = sqs.get_queue_by_name(queue_name: q).url
|
121
|
+
messages = sqs.client.get_queue_attributes(queue_url: url, attribute_names: ['All']).attributes[config[:metric]].to_i
|
122
|
+
|
123
|
+
if (config[:crit_under] >= 0 && messages < config[:crit_under]) || (config[:crit_over] >= 0 && messages > config[:crit_over])
|
124
|
+
crits << "#{messages} message(s) in #{q}"
|
125
|
+
elsif (config[:warn_under] >= 0 && messages < config[:warn_under]) || (config[:warn_over] >= 0 && messages > config[:warn_over])
|
126
|
+
warnings << "#{messages} message(s) in #{q}"
|
127
|
+
else
|
128
|
+
passing << "#{messages} message(s) in #{q}"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
if crits.any?
|
132
|
+
critical crits.join(', ').to_s
|
133
|
+
elsif warnings.any?
|
134
|
+
warning warnings.join(', ').to_s
|
135
|
+
else
|
136
|
+
ok "all queue(s): #{queues} are OK"
|
137
|
+
end
|
138
|
+
else
|
139
|
+
warn = false
|
140
|
+
crit = false
|
141
|
+
queues = []
|
142
|
+
exclusions = config[:exclude_queues]
|
143
|
+
|
144
|
+
sqs.queues(queue_name_prefix: config[:prefix]).each do |q|
|
145
|
+
messages = sqs.client.get_queue_attributes(queue_url: q.url, attribute_names: ['All']).attributes[config[:metric]].to_i
|
146
|
+
queue_name = q.attributes['QueueArn'].split(':').last
|
147
|
+
|
148
|
+
next if exclusions.include? queue_name
|
149
|
+
|
150
|
+
if (config[:crit_under] >= 0 && messages < config[:crit_under]) || (config[:crit_over] >= 0 && messages > config[:crit_over])
|
151
|
+
crit = true
|
152
|
+
queues << "#{messages} message(s) in #{queue_name} queue"
|
153
|
+
elsif (config[:warn_under] >= 0 && messages < config[:warn_under]) || (config[:warn_over] >= 0 && messages > config[:warn_over])
|
154
|
+
warn = true
|
155
|
+
queues << "#{messages} message(s) in #{queue_name} queue"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
if crit
|
160
|
+
critical queues.to_s
|
161
|
+
elsif warn
|
162
|
+
warning queues.to_s
|
163
|
+
else
|
164
|
+
ok "All queues matching prefix '#{config[:prefix]}' OK"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|