sensu-plugins-aws-boutetnico 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/LICENSE +22 -0
  4. data/README.md +333 -0
  5. data/bin/check-alb-target-group-health.rb +100 -0
  6. data/bin/check-asg-instances-created.rb +129 -0
  7. data/bin/check-asg-instances-inservice.rb +109 -0
  8. data/bin/check-autoscaling-cpucredits.rb +160 -0
  9. data/bin/check-beanstalk-elb-metric.rb +123 -0
  10. data/bin/check-beanstalk-health.rb +123 -0
  11. data/bin/check-certificate-expiry.rb +123 -0
  12. data/bin/check-cloudfront-tag.rb +70 -0
  13. data/bin/check-cloudwatch-alarm.rb +102 -0
  14. data/bin/check-cloudwatch-alarms.rb +89 -0
  15. data/bin/check-cloudwatch-composite-metric.rb +199 -0
  16. data/bin/check-cloudwatch-metric.rb +123 -0
  17. data/bin/check-configservice-rules.rb +76 -0
  18. data/bin/check-direct-connect-virtual-interfaces.rb +84 -0
  19. data/bin/check-dynamodb-capacity.rb +194 -0
  20. data/bin/check-dynamodb-throttle.rb +188 -0
  21. data/bin/check-ebs-burst-limit.rb +143 -0
  22. data/bin/check-ebs-snapshots.rb +104 -0
  23. data/bin/check-ec2-cpu_balance.rb +139 -0
  24. data/bin/check-ec2-filter.rb +190 -0
  25. data/bin/check-ec2-network.rb +133 -0
  26. data/bin/check-ecs-service-health.rb +155 -0
  27. data/bin/check-efs-metric.rb +145 -0
  28. data/bin/check-eip-allocation.rb +64 -0
  29. data/bin/check-elasticache-failover.rb +113 -0
  30. data/bin/check-elb-certs.rb +132 -0
  31. data/bin/check-elb-health-fog.rb +114 -0
  32. data/bin/check-elb-health-sdk.rb +176 -0
  33. data/bin/check-elb-health.rb +116 -0
  34. data/bin/check-elb-instances-inservice.rb +103 -0
  35. data/bin/check-elb-latency.rb +166 -0
  36. data/bin/check-elb-nodes.rb +133 -0
  37. data/bin/check-elb-sum-requests.rb +157 -0
  38. data/bin/check-emr-cluster.rb +144 -0
  39. data/bin/check-emr-steps.rb +90 -0
  40. data/bin/check-eni-status.rb +110 -0
  41. data/bin/check-expiring-reservations.rb +117 -0
  42. data/bin/check-instance-events.rb +154 -0
  43. data/bin/check-instance-health.rb +108 -0
  44. data/bin/check-instance-reachability.rb +107 -0
  45. data/bin/check-instances-count.rb +94 -0
  46. data/bin/check-kms-key.rb +73 -0
  47. data/bin/check-rds-events.rb +141 -0
  48. data/bin/check-rds-pending.rb +91 -0
  49. data/bin/check-rds.rb +382 -0
  50. data/bin/check-redshift-events.rb +108 -0
  51. data/bin/check-reserved-instances.rb +80 -0
  52. data/bin/check-route.rb +122 -0
  53. data/bin/check-route53-domain-expiration.rb +78 -0
  54. data/bin/check-s3-bucket-visibility.rb +176 -0
  55. data/bin/check-s3-bucket.rb +86 -0
  56. data/bin/check-s3-object.rb +205 -0
  57. data/bin/check-s3-tag.rb +70 -0
  58. data/bin/check-sensu-client.rb +184 -0
  59. data/bin/check-ses-limit.rb +89 -0
  60. data/bin/check-ses-statistics.rb +149 -0
  61. data/bin/check-sns-subscriptions.rb +52 -0
  62. data/bin/check-sqs-messages.rb +168 -0
  63. data/bin/check-subnet-ip-consumption.rb +234 -0
  64. data/bin/check-trustedadvisor-service-limits.rb +90 -0
  65. data/bin/check-vpc-nameservers.rb +87 -0
  66. data/bin/check-vpc-vpn.rb +98 -0
  67. data/bin/handler-ec2_node.rb +241 -0
  68. data/bin/handler-scale-asg-down.rb +131 -0
  69. data/bin/handler-scale-asg-up.rb +131 -0
  70. data/bin/handler-ses.rb +107 -0
  71. data/bin/handler-sns.rb +64 -0
  72. data/bin/metrics-asg.rb +156 -0
  73. data/bin/metrics-autoscaling-instance-count.rb +101 -0
  74. data/bin/metrics-billing.rb +97 -0
  75. data/bin/metrics-cloudfront.rb +159 -0
  76. data/bin/metrics-ec2-count.rb +137 -0
  77. data/bin/metrics-ec2-filter.rb +97 -0
  78. data/bin/metrics-elasticache.rb +166 -0
  79. data/bin/metrics-elb.rb +169 -0
  80. data/bin/metrics-emr-steps.rb +82 -0
  81. data/bin/metrics-rds.rb +153 -0
  82. data/bin/metrics-reservation-utilization.rb +84 -0
  83. data/bin/metrics-s3.rb +107 -0
  84. data/bin/metrics-ses.rb +62 -0
  85. data/bin/metrics-sqs.rb +98 -0
  86. data/bin/metrics-waf.rb +111 -0
  87. data/lib/sensu-plugins-aws.rb +4 -0
  88. data/lib/sensu-plugins-aws/cloudwatch-common.rb +92 -0
  89. data/lib/sensu-plugins-aws/common.rb +35 -0
  90. data/lib/sensu-plugins-aws/filter.rb +47 -0
  91. data/lib/sensu-plugins-aws/version.rb +8 -0
  92. metadata +456 -0
@@ -0,0 +1,103 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-elb-instance-inservice
4
+ #
5
+ # DESCRIPTION:
6
+ # Check Elastic Loudbalancer Instances are inService.
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
+ # all LoadBalancers
20
+ # ./check-elb-instance-inservice -r ${your_region}
21
+ # one loadBalancer
22
+ # ./check-elb-instance-inservice -r ${your_region} -l 'LoadBalancerName'
23
+ #
24
+ # NOTES:
25
+ # Based heavily on Peter Hoppe check-autoscaling-instances-inservices
26
+ #
27
+ # LICENSE:
28
+ # Peter Hoppe <peter.hoppe.extern@bertelsmann.de>
29
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
30
+ # for details.
31
+ #
32
+
33
+ require 'sensu-plugin/check/cli'
34
+ require 'aws-sdk'
35
+ require 'sensu-plugins-aws'
36
+
37
+ class CheckElbInstanceInService < Sensu::Plugin::Check::CLI
38
+ include Common
39
+ option :aws_region,
40
+ short: '-r AWS_REGION',
41
+ long: '--aws-region REGION',
42
+ description: 'AWS Region (defaults to us-east-1).',
43
+ default: ENV['AWS_REGION']
44
+
45
+ option :load_balancer,
46
+ short: '-l L',
47
+ long: '--load_balancer LoudBalancer',
48
+ description: 'LoadBalancer Name to check'
49
+
50
+ def elb
51
+ @elb ||= Aws::ElasticLoadBalancing::Client.new
52
+ end
53
+
54
+ def describe_elb(elb_name)
55
+ elb.describe_instance_health(
56
+ load_balancer_name: elb_name.to_s
57
+ )
58
+ end
59
+
60
+ def run
61
+ warning = 0
62
+ critical = 0
63
+ result = ''
64
+ if config[:load_balancer].nil?
65
+ elb.describe_load_balancers.load_balancer_descriptions.each do |load_balancer|
66
+ describe_elb(load_balancer.load_balancer_name).each do |instances|
67
+ instances.instance_states.each do |instance|
68
+ if instance.state == 'InService'
69
+ result += "#{instance.instance_id} state InService "
70
+ else
71
+ result += "#{instance.instance_id} state not InService "
72
+ warning += 1
73
+ end
74
+ end
75
+ if warning == instances.instance_states.length
76
+ critical = 1
77
+ end
78
+ end
79
+ end
80
+ else
81
+ describe_elb(config[:load_balancer]).each do |instances|
82
+ instances.instance_states.each do |instance|
83
+ if instance.state == 'InService'
84
+ result += "#{instance.instance_id} state InService "
85
+ else
86
+ result += "#{instance.instance_id} state not InService "
87
+ warning += 1
88
+ end
89
+ end
90
+ if warning == instances.instance_states.length
91
+ critical = 1
92
+ end
93
+ end
94
+ end
95
+ if critical == 1
96
+ critical result
97
+ elsif warning >= 1
98
+ warning result
99
+ else
100
+ ok result
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,166 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-elb-latency
4
+ #
5
+ #
6
+ # DESCRIPTION:
7
+ # This plugin checks the latency of an Amazon Elastic Load Balancer.
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
+ # Warning if any load balancer's latency is over 1 second, critical if over 3 seconds.
21
+ # check-elb-latency --warning-over 1 --critical-over 3
22
+ #
23
+ # Critical if "app" load balancer's latency is over 5 seconds, maximum of last one hour
24
+ # check-elb-latency --elb-names app --critical-over 5 --statistics maximum --period 3600
25
+ #
26
+ # NOTES:
27
+ #
28
+ # LICENSE:
29
+ # Copyright 2014 github.com/y13i
30
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
31
+ # for details.
32
+ #
33
+
34
+ require 'sensu-plugin/check/cli'
35
+ require 'sensu-plugins-aws'
36
+ require 'aws-sdk'
37
+
38
+ class CheckELBLatency < Sensu::Plugin::Check::CLI
39
+ include Common
40
+
41
+ option :aws_region,
42
+ short: '-r AWS_REGION',
43
+ long: '--aws-region REGION',
44
+ description: 'AWS Region (defaults to us-east-1).',
45
+ default: 'us-east-1'
46
+
47
+ option :elb_names,
48
+ short: '-l N',
49
+ long: '--elb-names NAMES',
50
+ proc: proc { |a| a.split(/[,;]\s*/) },
51
+ description: 'Load balancer names to check. Separated by , or ;. If not specified, check all load balancers'
52
+
53
+ option :end_time,
54
+ short: '-t T',
55
+ long: '--end-time TIME',
56
+ default: Time.now,
57
+ proc: proc { |a| Time.parse a },
58
+ description: 'CloudWatch metric statistics end time'
59
+
60
+ option :period,
61
+ short: '-p N',
62
+ long: '--period SECONDS',
63
+ default: 60,
64
+ proc: proc(&:to_i),
65
+ description: 'CloudWatch metric statistics period'
66
+
67
+ option :statistics,
68
+ short: '-S N',
69
+ long: '--statistics NAME',
70
+ default: :average,
71
+ proc: proc { |a| a.downcase.intern },
72
+ description: 'CloudWatch statistics method'
73
+
74
+ %w[warning critical].each do |severity|
75
+ option :"#{severity}_over",
76
+ long: "--#{severity}-over SECONDS",
77
+ proc: proc(&:to_f),
78
+ description: "Trigger a #{severity} if latancy is over specified seconds"
79
+ end
80
+
81
+ def elb
82
+ @elb ||= Aws::ElasticLoadBalancing::Client.new(aws_config)
83
+ end
84
+
85
+ def cloud_watch
86
+ @cloud_watch ||= Aws::CloudWatch::Client.new
87
+ end
88
+
89
+ def elbs
90
+ return @elbs if @elbs
91
+ @elbs = elb.describe_load_balancers.load_balancer_descriptions.to_a
92
+ @elbs.select! { |elb| config[:elb_names].include? elb.load_balancer_name } if config[:elb_names]
93
+ @elbs
94
+ end
95
+
96
+ def latency_metric(elb_name)
97
+ cloud_watch.get_metric_statistics(
98
+ namespace: 'AWS/ELB',
99
+ metric_name: 'Latency',
100
+ dimensions: [
101
+ {
102
+ name: 'LoadBalancerName',
103
+ value: elb_name
104
+ }
105
+ ],
106
+ start_time: config[:end_time] - config[:period],
107
+ end_time: config[:end_time],
108
+ statistics: [config[:statistics].to_s.capitalize],
109
+ period: config[:period],
110
+ unit: 'Seconds'
111
+ )
112
+ end
113
+
114
+ def latest_value(metric)
115
+ metric.datapoints.sort_by { |datapoint| datapoint[:timestamp] }.last[config[:statistics]]
116
+ end
117
+
118
+ def flag_alert(severity, message)
119
+ @severities[severity] = true
120
+ @message += message
121
+ end
122
+
123
+ def check_latency(elb)
124
+ metric = latency_metric elb.load_balancer_name
125
+ metric_value = begin
126
+ latest_value metric
127
+ rescue StandardError
128
+ 0
129
+ end
130
+
131
+ @severities.each_key do |severity|
132
+ threshold = config[:"#{severity}_over"]
133
+ next unless threshold
134
+ next if metric_value < threshold
135
+ flag_alert severity,
136
+ "; #{elbs.size == 1 ? nil : "#{elb.load_balancer_name}'s"} Latency is #{sprintf '%.3f', metric_value} seconds. (expected lower than #{sprintf '%.3f', threshold})"
137
+ break
138
+ end
139
+ end
140
+
141
+ def run
142
+ @message = if elbs.size == 1
143
+ elbs.first.load_balancer_name
144
+ else
145
+ "#{elbs.size} load balancers total"
146
+ end
147
+
148
+ @severities = {
149
+ critical: false,
150
+ warning: false
151
+ }
152
+
153
+ elbs.each { |elb| check_latency elb }
154
+
155
+ @message += "; (#{config[:statistics].to_s.capitalize} within #{config[:period]} seconds "
156
+ @message += "between #{config[:end_time] - config[:period]} to #{config[:end_time]})"
157
+
158
+ if @severities[:critical]
159
+ critical @message
160
+ elsif @severities[:warning]
161
+ warning @message
162
+ else
163
+ ok @message
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # check-elb-nodes
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin checks an AWS Elastic Load Balancer to ensure a minimum number
7
+ # or percentage of nodes are InService on the ELB
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
+ # Warning if the load balancer has 3 or fewer healthy nodes and critical if 2 or fewer
21
+ # check-elb-nodes --warn 3 --crit 2
22
+ #
23
+ # Warning if the load balancer has 50% or less healthy nodes and critical if 25% or less
24
+ # check-elb-nodes --warn_perc 50 --crit_perc 25
25
+ #
26
+ # NOTES:
27
+ #
28
+ # LICENSE:
29
+ # Copyright (c) 2013, Justin Lambert <jlambert@letsevenup.com>
30
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
31
+ # for details.
32
+ #
33
+
34
+ require 'sensu-plugin/check/cli'
35
+ require 'sensu-plugins-aws'
36
+ require 'aws-sdk'
37
+
38
+ class CheckELBNodes < Sensu::Plugin::Check::CLI
39
+ include Common
40
+
41
+ option :aws_region,
42
+ short: '-r AWS_REGION',
43
+ long: '--aws-region REGION',
44
+ description: 'AWS Region (defaults to us-east-1).',
45
+ default: 'us-east-1'
46
+
47
+ option :load_balancer,
48
+ short: '-n ELB_NAME',
49
+ long: '--name ELB_NAME',
50
+ description: 'The name of the ELB',
51
+ required: true
52
+
53
+ option :warn_under,
54
+ short: '-w WARN_NUM',
55
+ long: '--warn WARN_NUM',
56
+ description: 'Minimum number of nodes InService on the ELB to be considered a warning',
57
+ default: -1,
58
+ proc: proc(&:to_i)
59
+
60
+ option :crit_under,
61
+ short: '-c CRIT_NUM',
62
+ long: '--crit CRIT_NUM',
63
+ description: 'Minimum number of nodes InService on the ELB to be considered critical',
64
+ default: -1,
65
+ proc: proc(&:to_i)
66
+
67
+ option :warn_percent,
68
+ short: '-W WARN_PERCENT',
69
+ long: '--warn_perc WARN_PERCENT',
70
+ description: 'Warn when the percentage of InService nodes is at or below this number',
71
+ default: -1,
72
+ proc: proc(&:to_i)
73
+
74
+ option :crit_percent,
75
+ short: '-C CRIT_PERCENT',
76
+ long: '--crit_perc CRIT_PERCENT',
77
+ description: 'Minimum percentage of nodes needed to be InService',
78
+ default: -1,
79
+ proc: proc(&:to_i)
80
+
81
+ def aws_config
82
+ { access_key_id: config[:aws_access_key],
83
+ secret_access_key: config[:aws_secret_access_key],
84
+ region: config[:aws_region] }
85
+ end
86
+
87
+ def run
88
+ elb = Aws::ElasticLoadBalancing::Client.new(aws_config)
89
+
90
+ begin
91
+ instance_health = elb.describe_instance_health(load_balancer_name: config[:load_balancer])
92
+ rescue Aws::ElasticLoadBalancing::Errors::LoadBalancerNotFound
93
+ unknown "A load balancer with the name '#{config[:load_balancer]}' was not found"
94
+ end
95
+
96
+ num_instances = instance_health.instance_states.size
97
+ state = { 'OutOfService' => [], 'InService' => [], 'Unknown' => [] }
98
+ instance_health.instance_states.each do |instance|
99
+ state[instance.state] << instance.instance_id
100
+ end
101
+
102
+ message = "InService: #{state['InService'].count}"
103
+ if state['InService'].count > 0
104
+ message << " (#{state['InService'].join(', ')})"
105
+ end
106
+ message << "; OutOfService: #{state['OutOfService'].count}"
107
+ if state['OutOfService'].count > 0
108
+ message << " (#{state['OutOfService'].join(', ')})"
109
+ end
110
+ message << "; Unknown: #{state['Unknown'].count}"
111
+ if state['Unknown'].count > 0
112
+ message << " (#{state['Unknown'].join(', ')})"
113
+ end
114
+
115
+ if num_instances.zero?
116
+ critical 'ELB has no nodes'
117
+ elsif state['Unknown'].count == num_instances
118
+ unknown 'All nodes in unknown state'
119
+ elsif state['InService'].count.zero?
120
+ critical message
121
+ elsif config[:crit_under] > 0 && config[:crit_under] >= state['InService'].count
122
+ critical message
123
+ elsif config[:crit_percent] > 0 && config[:crit_percent] >= (state['InService'].count / num_instances) * 100
124
+ critical message
125
+ elsif config[:warn_under] > 0 && config[:warn_under] >= state['InService'].count
126
+ warning message
127
+ elsif config[:warn_percent] > 0 && config[:warn_percent] >= (state['InService'].count / num_instances) * 100
128
+ warning message
129
+ else
130
+ ok message
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,157 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # chwck-elb-sum-requests
4
+ #
5
+ # DESCRIPTION:
6
+ # Check ELB Sum Requests by CloudWatch API.
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
+ # Warning if any load balancer's sum request count is over 1000, critical if over 2000.
20
+ # check-elb-sum-requests --warning-over 1000 --critical-over 2000
21
+ #
22
+ # Critical if "app" load balancer's sum request count is over 10000, within last one hour
23
+ # check-elb-sum-requests --elb-names app --critical-over 10000 --period 3600
24
+ #
25
+ # NOTES:
26
+ #
27
+ # LICENSE:
28
+ # Copyright 2014 github.com/y13i
29
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
30
+ # for details.
31
+ #
32
+
33
+ require 'sensu-plugin/check/cli'
34
+ require 'sensu-plugins-aws'
35
+ require 'aws-sdk'
36
+
37
+ class CheckELBSumRequests < 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 :elb_names,
47
+ short: '-l N',
48
+ long: '--elb-names NAMES',
49
+ proc: proc { |a| a.split(/[,;]\s*/) },
50
+ description: 'Load balancer names to check. Separated by , or ;. If not specified, check all load balancers'
51
+
52
+ option :end_time,
53
+ short: '-t T',
54
+ long: '--end-time TIME',
55
+ default: Time.now,
56
+ proc: proc { |a| Time.parse a },
57
+ description: 'CloudWatch metric statistics end time'
58
+
59
+ option :period,
60
+ short: '-p N',
61
+ long: '--period SECONDS',
62
+ default: 60,
63
+ proc: proc(&:to_i),
64
+ description: 'CloudWatch metric statistics period'
65
+
66
+ %w[warning critical].each do |severity|
67
+ option :"#{severity}_over",
68
+ long: "--#{severity}-over COUNT",
69
+ proc: proc(&:to_f),
70
+ description: "Trigger a #{severity} if sum requests is over specified count"
71
+ end
72
+
73
+ def elb
74
+ @elb ||= Aws::ElasticLoadBalancing::Client.new(aws_config)
75
+ end
76
+
77
+ def cloud_watch
78
+ @cloud_watch ||= Aws::CloudWatch::Client.new
79
+ end
80
+
81
+ def elbs
82
+ return @elbs if @elbs
83
+ @elbs = elb.describe_load_balancers.load_balancer_descriptions.to_a
84
+ @elbs.select! { |elb| config[:elb_names].include? elb.load_balancer_name } if config[:elb_names]
85
+ @elbs
86
+ end
87
+
88
+ def request_count_metric(elb_name)
89
+ cloud_watch.get_metric_statistics(
90
+ namespace: 'AWS/ELB',
91
+ metric_name: 'RequestCount',
92
+ dimensions: [
93
+ {
94
+ name: 'LoadBalancerName',
95
+ value: elb_name
96
+ }
97
+ ],
98
+ start_time: config[:end_time] - config[:period],
99
+ end_time: config[:end_time],
100
+ statistics: ['Sum'],
101
+ period: config[:period]
102
+ )
103
+ end
104
+
105
+ def latest_value(metric)
106
+ metric.datapoints.sort_by { |datapoint| datapoint[:timestamp] }.last[:sum]
107
+ end
108
+
109
+ def flag_alert(severity, message)
110
+ @severities[severity] = true
111
+ @message += message
112
+ end
113
+
114
+ def check_sum_requests(elb)
115
+ metric = request_count_metric elb.load_balancer_name
116
+ metric_value = begin
117
+ latest_value metric
118
+ rescue StandardError
119
+ 0
120
+ end
121
+
122
+ @severities.each_key do |severity|
123
+ threshold = config[:"#{severity}_over"]
124
+ next unless threshold
125
+ next if metric_value < threshold
126
+ flag_alert severity,
127
+ "; #{elbs.size == 1 ? nil : "#{elb.load_balancer_name}'s"} Sum Requests is #{metric_value}. (expected lower than #{threshold})"
128
+ break
129
+ end
130
+ end
131
+
132
+ def run
133
+ @message = if elbs.size == 1
134
+ elbs.first.load_balancer_name
135
+ else
136
+ "#{elbs.size} load balancers total"
137
+ end
138
+
139
+ @severities = {
140
+ critical: false,
141
+ warning: false
142
+ }
143
+
144
+ elbs.each { |elb| check_sum_requests elb }
145
+
146
+ @message += "; (Sum within #{config[:period]} seconds "
147
+ @message += "between #{config[:end_time] - config[:period]} to #{config[:end_time]})"
148
+
149
+ if @severities[:critical]
150
+ critical @message
151
+ elsif @severities[:warning]
152
+ warning @message
153
+ else
154
+ ok @message
155
+ end
156
+ end
157
+ end