sensu-plugins-aws 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/CHANGELOG.md +17 -1
- data/README.md +22 -0
- data/bin/check-cloudwatch-metric.rb +1 -1
- data/bin/check-configservice-rules.rb +76 -0
- data/bin/check-ecs-service-health.rb +111 -0
- data/bin/check-emr-steps.rb +21 -10
- data/bin/check-kms-key.rb +73 -0
- data/bin/check-reserved-instances.rb +80 -0
- data/bin/check-s3-object.rb +1 -1
- data/bin/check-ses-statistics.rb +139 -0
- data/bin/check-sns-subscriptions.rb +52 -0
- data/bin/handler-ec2_node.rb +1 -1
- data/bin/handler-scale-asg-down.rb +131 -0
- data/bin/handler-scale-asg-up.rb +131 -0
- data/bin/metrics-elasticache.rb +1 -0
- data/bin/metrics-emr-steps.rb +1 -0
- data/bin/metrics-ses.rb +62 -0
- data/lib/sensu-plugins-aws/version.rb +1 -1
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmIxNTU0MzhkZTAzOGNhODc3OWY0ZmY2OTgzZThkMThjYjVhYmZlNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzlhNTNkN2ViMWYxMjdhZTQxN2FhNWQ2MTA1NmE5ZTA4ZDlkOGEwYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTNmNzc0YWM2ZGYyMTQzYTU0N2UyMGZjZGNiMDNiNzQwMGU3NDE1OWVjOTQx
|
10
|
+
N2FlMWQwZWY3ZDk0NmFkNjAwZjllMWY1NzU5YTdmZGZhMmRiNDhkZGY1NWFl
|
11
|
+
NDU5OWZhNTE5Zjg3NWU2N2IyNTVlNTM5Mjg5NzdlYmNiNzExOWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmM1Njk5YzcxMDZlNGIyNDcxNjc2Nzk1NTkxODlkZDhkMjAyMzVlZjU2MTU1
|
14
|
+
Y2FhODk3MTJmNzBiMTQ1NjVmMzI5ZDQ3N2U1ODJlMTZiOWRkODBjNjA3NjJh
|
15
|
+
YzJmYmVjZTZmNDZmMTQwMTM1ZWY2ZjEzMGIwMDBjZjhjZDZjZjQ=
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,21 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [2.4.0] - 2016-04-13
|
9
|
+
### Added
|
10
|
+
- Added metrics-ses.rb to collect SES metrics from GetSendStatistics
|
11
|
+
- Added check-ses-statistics.rb to check SES thresholds from GetSendStatistics
|
12
|
+
- check-emr-steps.rb: Added options to check different step status for check EMR steps
|
13
|
+
- metrics-emr.rb: Added cluster ID to EMR step metrics
|
14
|
+
- Added two handlers for increasing/decreasing desired capacity of autoscaling groups
|
15
|
+
- Implemented check for reserved instances
|
16
|
+
- Added check to ensure that some or all AWS ConfigService rules have full compliance
|
17
|
+
- Added check to ensure that SNS subscriptions is not pending
|
18
|
+
- handler-ec2_node.rb: protect from instance state_reason which may be nil
|
19
|
+
- Added check to ensure that some or all ECS Services are healthy on a cluster
|
20
|
+
- Added check to ensure a KMS key is available (enabled or disabled)
|
21
|
+
- metrics-elasticache.rb: retrieve BytesUsedForCache metric for redis nodes
|
22
|
+
|
8
23
|
## [2.3.0] - 2016-03-18
|
9
24
|
### Added
|
10
25
|
- Implemented metrics for EMR cluster steps
|
@@ -147,7 +162,8 @@ WARNING: This release contains major breaking changes that will impact all user
|
|
147
162
|
### Added
|
148
163
|
- initial release
|
149
164
|
|
150
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.
|
165
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.4.0...HEAD
|
166
|
+
[2.4.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/v2.3.0...2.4.0
|
151
167
|
[2.3.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/v2.2.0...2.3.0
|
152
168
|
[2.2.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/v2.1.1...2.2.0
|
153
169
|
[2.1.1]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.1.0...v2.1.1
|
data/README.md
CHANGED
@@ -16,6 +16,8 @@
|
|
16
16
|
|
17
17
|
**check-cloudwatch-alarm**
|
18
18
|
|
19
|
+
**check-configservice-rules**
|
20
|
+
|
19
21
|
**check-dynamodb-capacity.rb**
|
20
22
|
|
21
23
|
**check-dynamodb-throttle.rb**
|
@@ -28,6 +30,8 @@
|
|
28
30
|
|
29
31
|
**check-ec2-network.rb**
|
30
32
|
|
33
|
+
**check-ecs-service-health.rb**
|
34
|
+
|
31
35
|
**check-eip-allocation.rb**
|
32
36
|
|
33
37
|
**check-elasticache-failover.rb**
|
@@ -54,18 +58,26 @@
|
|
54
58
|
|
55
59
|
**check-instance-health.rb**
|
56
60
|
|
61
|
+
**check-kms-key.rb**
|
62
|
+
|
57
63
|
**check-rds-events.rb**
|
58
64
|
|
59
65
|
**check-rds.rb**
|
60
66
|
|
61
67
|
**check-redshift-events.rb**
|
62
68
|
|
69
|
+
**check-reserved-instances.rb**
|
70
|
+
|
63
71
|
**check-s3-bucket.rb**
|
64
72
|
|
65
73
|
**check-s3-object.rb**
|
66
74
|
|
67
75
|
**check-ses-limit.rb**
|
68
76
|
|
77
|
+
**check-ses-statistics.rb**
|
78
|
+
|
79
|
+
**check-sns-subscriptions**
|
80
|
+
|
69
81
|
**check-sqs-messages.rb**
|
70
82
|
|
71
83
|
**check-vpc-nameservers**
|
@@ -76,6 +88,10 @@
|
|
76
88
|
|
77
89
|
**handler-ec2_node.rb**
|
78
90
|
|
91
|
+
**handler-scale-asg-down.rb**
|
92
|
+
|
93
|
+
**handler-scale-asg-up.rb**
|
94
|
+
|
79
95
|
**handler-ses.rb**
|
80
96
|
|
81
97
|
**handler-sns.rb**
|
@@ -94,6 +110,8 @@
|
|
94
110
|
|
95
111
|
**metrics-emr-steps.rb**
|
96
112
|
|
113
|
+
**metrics-ses.rb**
|
114
|
+
|
97
115
|
**metrics-sqs.rb**
|
98
116
|
|
99
117
|
|
@@ -102,12 +120,14 @@
|
|
102
120
|
* /bin/check-autoscaling-cpucredits.rb
|
103
121
|
* /bin/check-beanstalk-elb-metric.rb
|
104
122
|
* /bin/check-certificate-expiry.rb
|
123
|
+
* /bin/check-configservice-rules.rb
|
105
124
|
* /bin/check-cloudwatch-alarm.rb
|
106
125
|
* /bin/check-dynamodb-capacity.rb
|
107
126
|
* /bin/check-dynamodb-throttle.rb
|
108
127
|
* /bin/check-ebs-snapshots.rb
|
109
128
|
* /bin/check-ec2-filter.rb
|
110
129
|
* /bin/check-ec2-network.rb
|
130
|
+
* /bin/check-ecs-service-health.rb
|
111
131
|
* /bin/check-elasticache-failover.rb
|
112
132
|
* /bin/check-elb-certs.rb
|
113
133
|
* /bin/check-elb-health-fog.rb
|
@@ -124,6 +144,7 @@
|
|
124
144
|
* /bin/check-redshift-events.rb
|
125
145
|
* /bin/check-s3-object.rb
|
126
146
|
* /bin/check-ses-limit.rb
|
147
|
+
* /bin/check-ses-statistics.rb
|
127
148
|
* /bin/check-sqs-messages.rb
|
128
149
|
* /bin/check-vpc-nameservers.rb
|
129
150
|
* /bin/check_vpc_vpn.py
|
@@ -138,6 +159,7 @@
|
|
138
159
|
* /bin/metrics-elb-full.rb
|
139
160
|
* /bin/metrics-elb.rb
|
140
161
|
* /bin/metrics-emr-steps.rb
|
162
|
+
* /bin/metrics-ses.rb
|
141
163
|
* /bin/metrics-sqs.rb
|
142
164
|
|
143
165
|
## Usage
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# gem: sensu-plugin
|
18
18
|
#
|
19
19
|
# USAGE:
|
20
|
-
# ./check-cloudwatch-metric -
|
20
|
+
# ./check-cloudwatch-metric -m CPUUtilization -d InstanceId=i-12345678,AvailabilityZone=us-east-1a -c 90
|
21
21
|
#
|
22
22
|
# NOTES:
|
23
23
|
#
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-configservice-rules
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin uses the AWS ConfigService API to check
|
7
|
+
# for rules compliance. CRITICAL for non-compliance,
|
8
|
+
# UNKNOWN for insufficient data.
|
9
|
+
#
|
10
|
+
# OUTPUT:
|
11
|
+
# plain-text
|
12
|
+
#
|
13
|
+
# PLATFORMS:
|
14
|
+
# Linux, Windows, Mac
|
15
|
+
#
|
16
|
+
# DEPENDENCIES:
|
17
|
+
# gem: aws-sdk
|
18
|
+
# gem: sensu-plugin
|
19
|
+
#
|
20
|
+
# USAGE:
|
21
|
+
# ./check-configservice-rules.rb -r {us-east-1|eu-west-1} [-c My_Config_Rule]
|
22
|
+
#
|
23
|
+
# NOTES:
|
24
|
+
# As of this writing, ConfigService rules are only available in us-east-1.
|
25
|
+
# All other region selections will return an AccessDeniedException
|
26
|
+
#
|
27
|
+
# LICENSE:
|
28
|
+
# Norm MacLennan <nmaclennan@cimpress.com>
|
29
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
30
|
+
# for details.
|
31
|
+
|
32
|
+
require 'sensu-plugin/check/cli'
|
33
|
+
require 'sensu-plugins-aws'
|
34
|
+
require 'aws-sdk'
|
35
|
+
|
36
|
+
class CheckConfigServiceRules < Sensu::Plugin::Check::CLI
|
37
|
+
include Common
|
38
|
+
|
39
|
+
option :aws_region,
|
40
|
+
short: '-r AWS_REGION',
|
41
|
+
long: '--aws-region AWS_REGION',
|
42
|
+
description: 'The AWS region in which to check rules. Currently only available in us-east-1.',
|
43
|
+
default: 'us-east-1'
|
44
|
+
|
45
|
+
option :config_rules,
|
46
|
+
short: '-c rule1,rule2',
|
47
|
+
long: '--config-rules rule1,rule2',
|
48
|
+
description: 'A list of config rules to consider. Default is all rules.'
|
49
|
+
|
50
|
+
def get_config_rules_data(rules = nil)
|
51
|
+
options = { config_rule_names: rules.split(',') } if rules
|
52
|
+
config_client = Aws::ConfigService::Client.new
|
53
|
+
config_client.describe_compliance_by_config_rule(options).compliance_by_config_rules
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_rule_names_by_compliance_type(rules, compliance_type)
|
57
|
+
rules.select { |r| r.compliance.compliance_type == compliance_type }.collect(&:config_rule_name)
|
58
|
+
end
|
59
|
+
|
60
|
+
def run
|
61
|
+
rules = get_config_rules_data(config[:config_rules])
|
62
|
+
|
63
|
+
noncompliant = get_rule_names_by_compliance_type rules, 'NON_COMPLIANT'
|
64
|
+
unknown = get_rule_names_by_compliance_type rules, 'INSUFFICIENT_DATA'
|
65
|
+
|
66
|
+
if noncompliant.any?
|
67
|
+
critical("Config rules in violation: #{noncompliant.join(',')}")
|
68
|
+
elsif unknown.any?
|
69
|
+
unknown("Config rules in unknown state: #{unknown.join(',')}")
|
70
|
+
else
|
71
|
+
ok
|
72
|
+
end
|
73
|
+
rescue => e
|
74
|
+
unknown "An error occurred processing AWS ConfigService API: #{e.message}"
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-ecs-service-health
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin uses the AWS ECS API to check the running
|
7
|
+
# and desired task counts for services on a cluster.
|
8
|
+
# Any services with fewer running than desired tasks will
|
9
|
+
# are considered unhealthy.
|
10
|
+
#
|
11
|
+
# CRIT: 0 = running < desired
|
12
|
+
# WARN: 0 < running < desired
|
13
|
+
# OK: running >= desired
|
14
|
+
#
|
15
|
+
# OUTPUT:
|
16
|
+
# plain-text
|
17
|
+
#
|
18
|
+
# PLATFORMS:
|
19
|
+
# Linux, Windows, Mac
|
20
|
+
#
|
21
|
+
# DEPENDENCIES:
|
22
|
+
# gem: aws-sdk
|
23
|
+
# gem: sensu-plugin
|
24
|
+
#
|
25
|
+
# USAGE:
|
26
|
+
# ./check-ecs-service-health.rb -r {us-east-1|eu-west-1} -c default [-s my-service]
|
27
|
+
#
|
28
|
+
# NOTES:
|
29
|
+
#
|
30
|
+
# LICENSE:
|
31
|
+
# Norm MacLennan <nmaclennan@cimpress.com>
|
32
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
33
|
+
# for details.
|
34
|
+
|
35
|
+
require 'sensu-plugin/check/cli'
|
36
|
+
require 'sensu-plugins-aws'
|
37
|
+
require 'aws-sdk'
|
38
|
+
|
39
|
+
class CheckEcsServiceHealth < Sensu::Plugin::Check::CLI
|
40
|
+
include Common
|
41
|
+
|
42
|
+
option :aws_region,
|
43
|
+
short: '-r AWS_REGION',
|
44
|
+
long: '--aws-region AWS_REGION',
|
45
|
+
description: 'The AWS region in which to check rules. Currently only available in us-east-1.',
|
46
|
+
default: 'us-east-1'
|
47
|
+
|
48
|
+
option :cluster_name,
|
49
|
+
short: '-c NAME',
|
50
|
+
long: '--cluster-name NAME',
|
51
|
+
description: 'The cluster to check services on.',
|
52
|
+
default: 'default'
|
53
|
+
|
54
|
+
option :services,
|
55
|
+
short: '-s SERVICE',
|
56
|
+
long: '--service NAME',
|
57
|
+
description: 'The service to check run status on.'
|
58
|
+
|
59
|
+
option :warn_as_crit,
|
60
|
+
short: '-w',
|
61
|
+
long: '--warn_as_crit',
|
62
|
+
description: 'Consider it critical when any desired tasks are not running. Otherwise, only 0 is critical.'
|
63
|
+
|
64
|
+
def ecs_client
|
65
|
+
@ecs_client ||= Aws::ECS::Client.new
|
66
|
+
end
|
67
|
+
|
68
|
+
# List of requested services or all services registered to the cluster
|
69
|
+
def service_list(cluster = 'default', services = nil)
|
70
|
+
return services.split ',' if services
|
71
|
+
ecs_client.list_services(cluster: cluster)['service_arns']
|
72
|
+
end
|
73
|
+
|
74
|
+
def service_details(cluster = 'default', services = nil)
|
75
|
+
ecs_client.describe_services(cluster: cluster, services: service_list(cluster, services))['services']
|
76
|
+
end
|
77
|
+
|
78
|
+
def bucket_service(running_count, desired_count)
|
79
|
+
if running_count == 0 && desired_count > 0
|
80
|
+
:critical
|
81
|
+
elsif running_count < desired_count
|
82
|
+
:warn
|
83
|
+
else
|
84
|
+
:ok
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Unhealthy if service has fewer running tasks than desired
|
89
|
+
def services_by_health(cluster = 'default', services = nil)
|
90
|
+
service_details(cluster, services).group_by { |s| bucket_service(s[:running_count], s[:desired_count]) }
|
91
|
+
end
|
92
|
+
|
93
|
+
def run
|
94
|
+
service_healths = services_by_health(config[:cluster_name], config[:services])
|
95
|
+
|
96
|
+
unhealthy = []
|
97
|
+
unhealthy.concat(service_healths[:critical]) if service_healths.key? :critical
|
98
|
+
unhealthy.concat(service_healths[:warn]) if service_healths.key? :warn
|
99
|
+
unhealthy = unhealthy.collect { |s| "#{s.service_name} (#{s.running_count}/#{s.desired_count})" }
|
100
|
+
|
101
|
+
if service_healths.key?(:critical) || (config[:warn_as_crit] && service_healths.key?(:warn))
|
102
|
+
critical("Unhealthy ECS Services: #{unhealthy.join ', '}")
|
103
|
+
elsif service_healths.key?(:warn)
|
104
|
+
warning("Unhealthy ECS Services: #{unhealthy.join ', '}")
|
105
|
+
else
|
106
|
+
ok
|
107
|
+
end
|
108
|
+
rescue => e
|
109
|
+
unknown "An error occurred processing AWS ECS API: #{e.message}"
|
110
|
+
end
|
111
|
+
end
|
data/bin/check-emr-steps.rb
CHANGED
@@ -8,13 +8,12 @@
|
|
8
8
|
# OUTPUT:
|
9
9
|
# plain-text
|
10
10
|
#
|
11
|
-
#
|
12
11
|
# DEPENDENCIES:
|
13
12
|
# gem: aws-sdk
|
14
13
|
# gem: sensu-plugin
|
15
14
|
#
|
16
15
|
# USAGE:
|
17
|
-
# check-emr-steps.rb -r us-west-2 -b 'My Cluster'
|
16
|
+
# check-emr-steps.rb -r us-west-2 -b 'My Cluster' -t FAILED -c 0
|
18
17
|
#
|
19
18
|
# This will alert on any failed steps in the past 10 minutes on the latest cluster
|
20
19
|
# with the name 'My Cluster'.
|
@@ -29,7 +28,7 @@ require 'sensu-plugins-aws'
|
|
29
28
|
require 'sensu-plugin/metric/cli'
|
30
29
|
require 'aws-sdk'
|
31
30
|
|
32
|
-
class CheckEMRSteps < Sensu::Plugin::
|
31
|
+
class CheckEMRSteps < Sensu::Plugin::Check::CLI
|
33
32
|
include Common
|
34
33
|
|
35
34
|
option :scheme,
|
@@ -50,6 +49,18 @@ class CheckEMRSteps < Sensu::Plugin::Metric::CLI::Graphite
|
|
50
49
|
description: 'The name of the EMR cluster',
|
51
50
|
required: true
|
52
51
|
|
52
|
+
option :status,
|
53
|
+
short: '-t STEP_STATUS',
|
54
|
+
long: '--step-status',
|
55
|
+
description: 'Step status to check, [PENDING RUNNING COMPLETED CANCELLED FAILED INTERRUPTED]',
|
56
|
+
default: 'FAILED'
|
57
|
+
|
58
|
+
option :count,
|
59
|
+
short: '-c COUNT',
|
60
|
+
long: '--count',
|
61
|
+
description: 'Max number of steps with this status.',
|
62
|
+
default: 0
|
63
|
+
|
53
64
|
def run
|
54
65
|
emr = Aws::EMR::Client.new(aws_config)
|
55
66
|
begin
|
@@ -60,19 +71,19 @@ class CheckEMRSteps < Sensu::Plugin::Metric::CLI::Graphite
|
|
60
71
|
|
61
72
|
steps = emr.list_steps(
|
62
73
|
cluster_id: cluster.id,
|
63
|
-
step_states: [
|
74
|
+
step_states: config[:status]
|
64
75
|
).steps
|
65
76
|
|
66
77
|
messages = []
|
67
78
|
now = Time.new
|
68
79
|
failed = steps.select { |step| now - step.status.timeline.end_date_time < 10 * 60 }
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
ok
|
80
|
+
if failed.size > config[:count]
|
81
|
+
failed.each_entry { |step| messages << "Step #{step.id} '#{step.name}' has failed on cluster #{cluster.id} '#{cluster.name}'" }
|
82
|
+
if messages.count > 0
|
83
|
+
critical("#{messages.count} #{messages.count > 1 ? 'steps have' : 'step has'} failed: #{messages.join(',')}")
|
84
|
+
end
|
75
85
|
end
|
86
|
+
ok
|
76
87
|
end
|
77
88
|
end
|
78
89
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-kms-key
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Check KMS values by KMS 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
|
+
# check-kms-key -k key_id
|
20
|
+
#
|
21
|
+
# Critical if KMS key id doesn't exist
|
22
|
+
# Warning if KMS key id exists but is not enabled
|
23
|
+
# Ok if KMS key id exists and is enabled
|
24
|
+
# Unknown if no key_id is provided
|
25
|
+
#
|
26
|
+
# NOTES:
|
27
|
+
#
|
28
|
+
# LICENSE:
|
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 CheckKMSKey < 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.',
|
44
|
+
default: 'us-east-1'
|
45
|
+
|
46
|
+
option :key_id,
|
47
|
+
short: '-k ID',
|
48
|
+
long: '--key-id ID',
|
49
|
+
description: 'KMS key identifier',
|
50
|
+
default: nil
|
51
|
+
|
52
|
+
def kms_client
|
53
|
+
@kms_client ||= Aws::KMS::Client.new
|
54
|
+
end
|
55
|
+
|
56
|
+
def check_key(id)
|
57
|
+
return kms_client.describe_key(key_id: id)['key_metadata']['enabled']
|
58
|
+
rescue Aws::KMS::Errors::NotFoundException
|
59
|
+
critical 'Key doesnt exist'
|
60
|
+
rescue => e
|
61
|
+
unknown "Failed to check key #{id}: #{e}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def run
|
65
|
+
if config[:key_id].nil?
|
66
|
+
unknown 'No KMS key id provided. See help for usage details'
|
67
|
+
elsif check_key(config[:key_id])
|
68
|
+
ok 'Key exists and is enabled'
|
69
|
+
else
|
70
|
+
warning 'Key exists but is not enabled'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-reserved-instances
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin checks if reserved instances expire soon.
|
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-reserved-instances.rb --aws-region eu-west-1 --use-iam
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
#
|
23
|
+
# LICENSE:
|
24
|
+
# Copyright (c) 2015, 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 CheckReservedInstances < 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
|
+
option :warning,
|
43
|
+
description: 'Warn if expire date is lower age in seconds',
|
44
|
+
short: '-w SECONDS',
|
45
|
+
long: '--warning SECONDS',
|
46
|
+
default: 60 * 60 * 24 * 5,
|
47
|
+
proc: proc(&:to_i)
|
48
|
+
|
49
|
+
option :critical,
|
50
|
+
description: 'Critical if expire date is lower age in seconds',
|
51
|
+
short: '-c SECONDS',
|
52
|
+
long: '--critical SECONDS',
|
53
|
+
default: 60 * 60 * 24 * 30 * 2,
|
54
|
+
proc: proc(&:to_i)
|
55
|
+
|
56
|
+
def run
|
57
|
+
reserved_instances_critical = []
|
58
|
+
reserved_instances_warning = []
|
59
|
+
|
60
|
+
ec2 = Aws::EC2::Client.new
|
61
|
+
reserved_instances = ec2.describe_reserved_instances(filters: [{ name: 'state', values: ['active'] }]).reserved_instances
|
62
|
+
|
63
|
+
reserved_instances.each do |reserved_instance|
|
64
|
+
age = reserved_instance.end.to_i - Time.now.to_i
|
65
|
+
if age < config[:critical]
|
66
|
+
reserved_instances_critical << reserved_instance.reserved_instances_id
|
67
|
+
elsif age < config[:warning]
|
68
|
+
reserved_instances_warning << reserved_instance.reserved_instances_id
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
if !reserved_instances_critical.empty?
|
73
|
+
critical "Reserved instances will expire soon - #{reserved_instances_critical}"
|
74
|
+
elsif !reserved_instances_warning.empty?
|
75
|
+
warning "Reserved instances will expire soon - #{reserved_instances_warning}"
|
76
|
+
end
|
77
|
+
|
78
|
+
ok "#{reserved_instances.size} reserved instances"
|
79
|
+
end
|
80
|
+
end
|
data/bin/check-s3-object.rb
CHANGED
@@ -0,0 +1,139 @@
|
|
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/metric/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
|
+
|
49
|
+
option :low_delivery_crit,
|
50
|
+
short: '-L COUNT',
|
51
|
+
long: '--low_delivery_crit',
|
52
|
+
description: 'Number of delivery attempts to alert below.',
|
53
|
+
default: 0
|
54
|
+
|
55
|
+
option :delivery_warn,
|
56
|
+
short: '-d COUNT',
|
57
|
+
long: '--delivery_warn',
|
58
|
+
description: 'Number of delivery attempts to warn above.',
|
59
|
+
default: 0
|
60
|
+
|
61
|
+
option :delivery_crit,
|
62
|
+
short: '-D COUNT',
|
63
|
+
long: '--delivery_crit',
|
64
|
+
description: 'Number of delivery attempts to alert above.',
|
65
|
+
default: 0
|
66
|
+
|
67
|
+
option :complaint_warn,
|
68
|
+
short: '-c COUNT',
|
69
|
+
long: '--complaint_warn',
|
70
|
+
description: 'Number of complaints to warn above.',
|
71
|
+
default: 0
|
72
|
+
|
73
|
+
option :complaint_crit,
|
74
|
+
short: '-C COUNT',
|
75
|
+
long: '--complaint_crit',
|
76
|
+
description: 'Number of complaints to alert above.',
|
77
|
+
default: 0
|
78
|
+
|
79
|
+
option :reject_warn,
|
80
|
+
short: '-j COUNT',
|
81
|
+
long: '--reject_warn',
|
82
|
+
description: 'Number of rejects to warn above.',
|
83
|
+
default: 0
|
84
|
+
|
85
|
+
option :reject_crit,
|
86
|
+
short: '-J COUNT',
|
87
|
+
long: '--reject_crit',
|
88
|
+
description: 'Number of rejects to alert above.',
|
89
|
+
default: 0
|
90
|
+
|
91
|
+
option :bounce_warn,
|
92
|
+
short: '-b COUNT',
|
93
|
+
long: '--bounce_warn',
|
94
|
+
description: 'Number of bounces to warn above.',
|
95
|
+
default: 0
|
96
|
+
|
97
|
+
option :bounce_crit,
|
98
|
+
short: '-B COUNT',
|
99
|
+
long: '--bounce_crit',
|
100
|
+
description: 'Number of bounces to alert above.',
|
101
|
+
default: 0
|
102
|
+
|
103
|
+
def run
|
104
|
+
ses = Aws::SES::Client.new(aws_config)
|
105
|
+
begin
|
106
|
+
response = ses.get_send_statistics
|
107
|
+
|
108
|
+
unknown 'Empty response from AWS SES API' if response.empty? # Can this happen?
|
109
|
+
unknown 'No data points from AWS SES API' if response.send_data_points.empty?
|
110
|
+
|
111
|
+
data_point = response.send_data_points[-1]
|
112
|
+
bounces = data_point.bounces
|
113
|
+
rejects = data_point.rejects
|
114
|
+
complaints = data_point.complaints
|
115
|
+
delivery_attempts = data_point.delivery_attempts
|
116
|
+
|
117
|
+
message = "SES stats for #{data_point.timestamp}: "\
|
118
|
+
"#{delivery_attempts} delivery attempts, #{bounces} bounces, #{rejects} rejects, #{complaints} complaints"
|
119
|
+
|
120
|
+
if config[:complaint_crit] > 0 && config[:complaint_crit] <= complaints || \
|
121
|
+
config[:reject_crit] > 0 && config[:reject_crit] <= rejects || \
|
122
|
+
config[:bounce_crit] > 0 && config[:bounce_crit] <= bounces || \
|
123
|
+
config[:low_delivery_crit] > 0 && config[:low_delivery_crit] > bounces || \
|
124
|
+
config[:delivery_crit] > 0 && config[:delivery_crit] <= bounces
|
125
|
+
|
126
|
+
critical message
|
127
|
+
elsif config[:complaint_warn] > 0 && config[:complaint_warn] <= complaints || \
|
128
|
+
config[:reject_warn] > 0 && config[:reject_warn] <= rejects || \
|
129
|
+
config[:bounce_warn] > 0 && config[:bounce_warn] <= bounces || \
|
130
|
+
config[:low_delivery_warn] > 0 && config[:low_delivery_warn] > bounces || \
|
131
|
+
config[:delivery_warn] > 0 && config[:delivery_warn] <= bounces
|
132
|
+
|
133
|
+
warning message
|
134
|
+
else
|
135
|
+
ok message
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
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' }
|
48
|
+
|
49
|
+
critical "#{pending_confirmations.size} pending confirmations" unless pending_confirmations.empty?
|
50
|
+
ok
|
51
|
+
end
|
52
|
+
end
|
data/bin/handler-ec2_node.rb
CHANGED
@@ -169,7 +169,7 @@ class Ec2Node < Sensu::Handler
|
|
169
169
|
# method returns True
|
170
170
|
|
171
171
|
# Returns instance state reason in AWS i.e: "Client.UserInitiatedShutdown"
|
172
|
-
instance_state_reason = instances.instances[0].state_reason.code
|
172
|
+
instance_state_reason = instances.instances[0].state_reason.nil? ? nil : instances.instances[0].state_reason.code
|
173
173
|
# Returns the instance state i.e: "terminated"
|
174
174
|
instance_state = instances.instances[0].state.name
|
175
175
|
|
@@ -0,0 +1,131 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# handler-scale-down-asg
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# => Decreases the desired capacity of an AutoscalingGroup
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-plugin
|
16
|
+
# gem: aws-sdk
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
# -j JSONCONFIG - The name of a json config file to be used
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
# Json config by default should be named asg_scaler.json and should have 2 levels.
|
23
|
+
# First level contains: "asg_scaler"
|
24
|
+
# Second level contains: "autoscaling_group" and "cooldown_period"
|
25
|
+
# example of a valid asg_scaler.json:
|
26
|
+
# {
|
27
|
+
# "asg_scaler":
|
28
|
+
# {
|
29
|
+
# "autoscaling_group":"SomeGroupName",
|
30
|
+
# "cooldown_period":"36"
|
31
|
+
# }
|
32
|
+
# }
|
33
|
+
#
|
34
|
+
# LICENSE:
|
35
|
+
# Brian Sizemore <bpsizemore@gmail.com>
|
36
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
37
|
+
# for details.
|
38
|
+
#
|
39
|
+
|
40
|
+
require 'aws-sdk'
|
41
|
+
require 'json'
|
42
|
+
require 'sensu-handler'
|
43
|
+
|
44
|
+
class AsgScaler < Sensu::Handler
|
45
|
+
option :json_config,
|
46
|
+
description: 'Name of the json config file',
|
47
|
+
short: '-j JSONCONFIG',
|
48
|
+
long: '--json JSONCONFIG',
|
49
|
+
default: 'asg_scaler'
|
50
|
+
|
51
|
+
def autoscaling_group
|
52
|
+
get_setting('autoscaling_group')
|
53
|
+
end
|
54
|
+
|
55
|
+
def cooldown_period
|
56
|
+
get_setting('cooldown_period')
|
57
|
+
end
|
58
|
+
|
59
|
+
def json_config
|
60
|
+
cli ||= AsgScaler.new
|
61
|
+
cli.config[:json_config]
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_setting(name)
|
65
|
+
config_file ||= File.read("#{json_config}.json")
|
66
|
+
config ||= JSON.parse(config_file)
|
67
|
+
config['asg_scaler'][name]
|
68
|
+
end
|
69
|
+
|
70
|
+
def handle
|
71
|
+
@asg = autoscaling_group
|
72
|
+
@autoscaling = Aws::AutoScaling::Client.new
|
73
|
+
if !out_of_cooldown
|
74
|
+
puts "An autoscaling event took place within the past #{cooldown_period} minutes. No action will be taken."
|
75
|
+
else
|
76
|
+
puts "No event has taken place within the past #{cooldown_period} minutes. Proceeding..."
|
77
|
+
begin_scaling
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def asg_min_instances
|
82
|
+
resp = @autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: [@asg],
|
83
|
+
max_records: 1)
|
84
|
+
resp[0][0][3]
|
85
|
+
end
|
86
|
+
|
87
|
+
def filter_silenced
|
88
|
+
# The inhereted filter_silenced method is not working, currently investigating.
|
89
|
+
# Handler works properly with this spoofed method.
|
90
|
+
end
|
91
|
+
|
92
|
+
def out_of_cooldown
|
93
|
+
resp = @autoscaling.describe_scaling_activities(auto_scaling_group_name: @asg,
|
94
|
+
max_records: 1)
|
95
|
+
resp = resp[0][0][4].to_s
|
96
|
+
resp = resp.sub(' ', 'T')
|
97
|
+
resp = resp.sub(' UTC', '+00:00')
|
98
|
+
|
99
|
+
# Time of last autoscaling event
|
100
|
+
aws = DateTime.iso8601(resp)
|
101
|
+
|
102
|
+
# Current System Time
|
103
|
+
now = DateTime.now.new_offset(0)
|
104
|
+
diff = (now - aws).to_f # This produces time since last event in days
|
105
|
+
diff = diff * 24 * 60 # This produces the time since last event in minutes
|
106
|
+
diff > cooldown_period.to_f
|
107
|
+
end
|
108
|
+
|
109
|
+
def current_size
|
110
|
+
resp = @autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: [@asg],
|
111
|
+
max_records: 1)
|
112
|
+
resp[0][0][5]
|
113
|
+
end
|
114
|
+
|
115
|
+
def scale_down
|
116
|
+
size = current_size.to_i
|
117
|
+
new_size = size - 1
|
118
|
+
puts 'scaling down...'
|
119
|
+
@autoscaling.set_desired_capacity(auto_scaling_group_name: @asg,
|
120
|
+
desired_capacity: new_size)
|
121
|
+
end
|
122
|
+
|
123
|
+
def begin_scaling
|
124
|
+
stack_size = current_size
|
125
|
+
if stack_size > asg_min_instances
|
126
|
+
scale_down
|
127
|
+
else
|
128
|
+
puts 'The cluster has the minimum amount of instances. No action will be taken.'
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# handler-scale-up-asg
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# => Increases the desired capacity of an AutoscalingGroup
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-plugin
|
16
|
+
# gem: aws-sdk
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
# -j JSONCONFIG - The name of a json config file to be used
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
# Json config by default should be named asg_scaler.json and should have 2 levels.
|
23
|
+
# First level contains: "asg_scaler"
|
24
|
+
# Second level contains: "autoscaling_group" and "cooldown_period"
|
25
|
+
# example of a valid asg_scaler.json:
|
26
|
+
# {
|
27
|
+
# "asg_scaler":
|
28
|
+
# {
|
29
|
+
# "autoscaling_group":"SomeGroupName",
|
30
|
+
# "cooldown_period":"36"
|
31
|
+
# }
|
32
|
+
# }
|
33
|
+
#
|
34
|
+
# LICENSE:
|
35
|
+
# Brian Sizemore <bpsizemore@gmail.com>
|
36
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
37
|
+
# for details.
|
38
|
+
#
|
39
|
+
|
40
|
+
require 'aws-sdk'
|
41
|
+
require 'json'
|
42
|
+
require 'sensu-handler'
|
43
|
+
|
44
|
+
class AsgScaler < Sensu::Handler
|
45
|
+
option :json_config,
|
46
|
+
description: 'Name of the json config file',
|
47
|
+
short: '-j JSONCONFIG',
|
48
|
+
long: '--json JSONCONFIG',
|
49
|
+
default: 'asg_scaler'
|
50
|
+
|
51
|
+
def autoscaling_group
|
52
|
+
get_setting('autoscaling_group')
|
53
|
+
end
|
54
|
+
|
55
|
+
def cooldown_period
|
56
|
+
get_setting('cooldown_period')
|
57
|
+
end
|
58
|
+
|
59
|
+
def json_config
|
60
|
+
cli ||= AsgScaler.new
|
61
|
+
cli.config[:json_config]
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_setting(name)
|
65
|
+
config_file ||= File.read("#{json_config}.json")
|
66
|
+
config ||= JSON.parse(config_file)
|
67
|
+
config['asg_scaler'][name]
|
68
|
+
end
|
69
|
+
|
70
|
+
def handle
|
71
|
+
@asg = autoscaling_group
|
72
|
+
@autoscaling = Aws::AutoScaling::Client.new
|
73
|
+
if !out_of_cooldown
|
74
|
+
puts "An autoscaling event took place within the past #{cooldown_period} minutes. No action will be taken."
|
75
|
+
else
|
76
|
+
puts "No event has taken place within the past #{cooldown_period} minutes. Proceeding..."
|
77
|
+
begin_scaling
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def asg_max_instances
|
82
|
+
resp = @autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: [@asg],
|
83
|
+
max_records: 1)
|
84
|
+
resp[0][0][4]
|
85
|
+
end
|
86
|
+
|
87
|
+
def filter_silenced
|
88
|
+
# The inhereted filter_silenced method is not working, currently investigating.
|
89
|
+
# Handler works properly with this spoofed method.
|
90
|
+
end
|
91
|
+
|
92
|
+
def out_of_cooldown
|
93
|
+
resp = @autoscaling.describe_scaling_activities(auto_scaling_group_name: @asg,
|
94
|
+
max_records: 1)
|
95
|
+
resp = resp[0][0][4].to_s
|
96
|
+
resp = resp.sub(' ', 'T')
|
97
|
+
resp = resp.sub(' UTC', '+00:00')
|
98
|
+
|
99
|
+
# Time of last autoscaling event
|
100
|
+
aws = DateTime.iso8601(resp)
|
101
|
+
|
102
|
+
# Current System Time
|
103
|
+
now = DateTime.now.new_offset(0)
|
104
|
+
diff = (now - aws).to_f # This produces time since last event in days
|
105
|
+
diff = diff * 24 * 60 # This produces the time since last event in minutes
|
106
|
+
diff > cooldown_period.to_f
|
107
|
+
end
|
108
|
+
|
109
|
+
def current_size
|
110
|
+
resp = @autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: [@asg],
|
111
|
+
max_records: 1)
|
112
|
+
resp[0][0][5]
|
113
|
+
end
|
114
|
+
|
115
|
+
def scale_up
|
116
|
+
size = current_size.to_i
|
117
|
+
new_size = size + 1
|
118
|
+
puts 'scaling down...'
|
119
|
+
@autoscaling.set_desired_capacity(auto_scaling_group_name: @asg,
|
120
|
+
desired_capacity: new_size)
|
121
|
+
end
|
122
|
+
|
123
|
+
def begin_scaling
|
124
|
+
stack_size = current_size
|
125
|
+
if stack_size < asg_max_instances
|
126
|
+
scale_up
|
127
|
+
else
|
128
|
+
puts 'The cluster has the maximum amount of instances. No action will be taken.'
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
data/bin/metrics-elasticache.rb
CHANGED
@@ -116,6 +116,7 @@ class ElastiCacheMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
116
116
|
statistic_type = {
|
117
117
|
'redis' => {
|
118
118
|
'CPUUtilization' => 'Percent',
|
119
|
+
'BytesUsedForCache' => 'Bytes',
|
119
120
|
'SwapUsage' => 'Bytes',
|
120
121
|
'FreeableMemory' => 'Bytes',
|
121
122
|
'NetworkBytesIn' => 'Bytes',
|
data/bin/metrics-emr-steps.rb
CHANGED
@@ -74,6 +74,7 @@ class EMRStepMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
74
74
|
STATUS.each_entry { |status| data[status] = 0 }
|
75
75
|
cluster_steps(emr, cluster.id, data)
|
76
76
|
safe_name = config[:cluster_name].tr(' ', '_')
|
77
|
+
output config[:scheme] + '.' + safe_name + '.id.' + cluster_id
|
77
78
|
STATUS.each_entry { |status| output config[:scheme] + '.' + safe_name + '.step.' + status, data[status] }
|
78
79
|
end
|
79
80
|
ok
|
data/bin/metrics-ses.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# metrics-ses
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Lists SES send statistics
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# metric data
|
10
|
+
#
|
11
|
+
# DEPENDENCIES:
|
12
|
+
# gem: aws-sdk
|
13
|
+
# gem: sensu-plugin
|
14
|
+
#
|
15
|
+
# USAGE:
|
16
|
+
# metrics-ses.rb -r us-west-2
|
17
|
+
#
|
18
|
+
# This will list out the statistics for the most recent 15 minutes from SES
|
19
|
+
#
|
20
|
+
# NOTES:
|
21
|
+
#
|
22
|
+
# LICENSE:
|
23
|
+
# Brandon Smith <freedom@reardencode.com>
|
24
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
25
|
+
# for details.
|
26
|
+
|
27
|
+
require 'sensu-plugins-aws'
|
28
|
+
require 'sensu-plugin/metric/cli'
|
29
|
+
require 'aws-sdk'
|
30
|
+
|
31
|
+
class SesMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
32
|
+
include Common
|
33
|
+
|
34
|
+
option :scheme,
|
35
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
36
|
+
short: '-s SCHEME',
|
37
|
+
long: '--scheme SCHEME',
|
38
|
+
default: 'sensu.aws.ses'
|
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
|
+
def run
|
47
|
+
ses = Aws::SES::Client.new(aws_config)
|
48
|
+
begin
|
49
|
+
response = ses.get_send_statistics
|
50
|
+
|
51
|
+
unknown 'Empty response from AWS SES API' if response.empty? # Can this happen?
|
52
|
+
unknown 'No data points from AWS SES API' if response.send_data_points.empty?
|
53
|
+
|
54
|
+
data_point = response.send_data_points[-1]
|
55
|
+
output config[:scheme] + '.bounces', data_point.bounces
|
56
|
+
output config[:scheme] + '.rejects', data_point.rejects
|
57
|
+
output config[:scheme] + '.complaints', data_point.complaints
|
58
|
+
output config[:scheme] + '.delivery_attempts', data_point.delivery_attempts
|
59
|
+
end
|
60
|
+
ok
|
61
|
+
end
|
62
|
+
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: 2.
|
4
|
+
version: 2.4.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: 2016-
|
11
|
+
date: 2016-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -232,12 +232,14 @@ executables:
|
|
232
232
|
- check-certificate-expiry.rb
|
233
233
|
- check-cloudwatch-alarm.rb
|
234
234
|
- check-cloudwatch-metric.rb
|
235
|
+
- check-configservice-rules.rb
|
235
236
|
- check-dynamodb-capacity.rb
|
236
237
|
- check-dynamodb-throttle.rb
|
237
238
|
- check-ebs-snapshots.rb
|
238
239
|
- check-ec2-cpu_balance.rb
|
239
240
|
- check-ec2-filter.rb
|
240
241
|
- check-ec2-network.rb
|
242
|
+
- check-ecs-service-health.rb
|
241
243
|
- check-eip-allocation.rb
|
242
244
|
- check-elasticache-failover.rb
|
243
245
|
- check-elb-certs.rb
|
@@ -251,18 +253,24 @@ executables:
|
|
251
253
|
- check-emr-steps.rb
|
252
254
|
- check-instance-events.rb
|
253
255
|
- check-instance-health.rb
|
256
|
+
- check-kms-key.rb
|
254
257
|
- check-rds-events.rb
|
255
258
|
- check-rds.rb
|
256
259
|
- check-redshift-events.rb
|
260
|
+
- check-reserved-instances.rb
|
257
261
|
- check-s3-bucket.rb
|
258
262
|
- check-s3-object.rb
|
259
263
|
- check-sensu-client.rb
|
260
264
|
- check-ses-limit.rb
|
265
|
+
- check-ses-statistics.rb
|
266
|
+
- check-sns-subscriptions.rb
|
261
267
|
- check-sqs-messages.rb
|
262
268
|
- check-trustedadvisor-service-limits.rb
|
263
269
|
- check-vpc-nameservers.rb
|
264
270
|
- check-vpc-vpn.rb
|
265
271
|
- handler-ec2_node.rb
|
272
|
+
- handler-scale-asg-down.rb
|
273
|
+
- handler-scale-asg-up.rb
|
266
274
|
- handler-ses.rb
|
267
275
|
- handler-sns.rb
|
268
276
|
- metrics-autoscaling-instance-count.rb
|
@@ -272,6 +280,7 @@ executables:
|
|
272
280
|
- metrics-elb-full.rb
|
273
281
|
- metrics-elb.rb
|
274
282
|
- metrics-emr-steps.rb
|
283
|
+
- metrics-ses.rb
|
275
284
|
- metrics-sqs.rb
|
276
285
|
extensions: []
|
277
286
|
extra_rdoc_files: []
|
@@ -284,12 +293,14 @@ files:
|
|
284
293
|
- bin/check-certificate-expiry.rb
|
285
294
|
- bin/check-cloudwatch-alarm.rb
|
286
295
|
- bin/check-cloudwatch-metric.rb
|
296
|
+
- bin/check-configservice-rules.rb
|
287
297
|
- bin/check-dynamodb-capacity.rb
|
288
298
|
- bin/check-dynamodb-throttle.rb
|
289
299
|
- bin/check-ebs-snapshots.rb
|
290
300
|
- bin/check-ec2-cpu_balance.rb
|
291
301
|
- bin/check-ec2-filter.rb
|
292
302
|
- bin/check-ec2-network.rb
|
303
|
+
- bin/check-ecs-service-health.rb
|
293
304
|
- bin/check-eip-allocation.rb
|
294
305
|
- bin/check-elasticache-failover.rb
|
295
306
|
- bin/check-elb-certs.rb
|
@@ -303,19 +314,25 @@ files:
|
|
303
314
|
- bin/check-emr-steps.rb
|
304
315
|
- bin/check-instance-events.rb
|
305
316
|
- bin/check-instance-health.rb
|
317
|
+
- bin/check-kms-key.rb
|
306
318
|
- bin/check-rds-events.rb
|
307
319
|
- bin/check-rds.rb
|
308
320
|
- bin/check-redshift-events.rb
|
321
|
+
- bin/check-reserved-instances.rb
|
309
322
|
- bin/check-s3-bucket.rb
|
310
323
|
- bin/check-s3-object.rb
|
311
324
|
- bin/check-sensu-client.rb
|
312
325
|
- bin/check-ses-limit.rb
|
326
|
+
- bin/check-ses-statistics.rb
|
327
|
+
- bin/check-sns-subscriptions.rb
|
313
328
|
- bin/check-sqs-messages.rb
|
314
329
|
- bin/check-trustedadvisor-service-limits.rb
|
315
330
|
- bin/check-vpc-nameservers.rb
|
316
331
|
- bin/check-vpc-vpn.rb
|
317
332
|
- bin/check_vpc_vpn.py
|
318
333
|
- bin/handler-ec2_node.rb
|
334
|
+
- bin/handler-scale-asg-down.rb
|
335
|
+
- bin/handler-scale-asg-up.rb
|
319
336
|
- bin/handler-ses.rb
|
320
337
|
- bin/handler-sns.rb
|
321
338
|
- bin/metrics-autoscaling-instance-count.rb
|
@@ -325,6 +342,7 @@ files:
|
|
325
342
|
- bin/metrics-elb-full.rb
|
326
343
|
- bin/metrics-elb.rb
|
327
344
|
- bin/metrics-emr-steps.rb
|
345
|
+
- bin/metrics-ses.rb
|
328
346
|
- bin/metrics-sqs.rb
|
329
347
|
- lib/sensu-plugins-aws.rb
|
330
348
|
- lib/sensu-plugins-aws/cloudwatch-common.rb
|