sensu-plugins-aws 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.md +30 -1
- data/README.md +3 -0
- data/bin/check-beanstalk-health.rb +12 -1
- data/bin/check-ec2-filter.rb +1 -1
- data/bin/check-ecs-service-health.rb +11 -2
- data/bin/check-elb-health-sdk.rb +56 -12
- data/bin/check-instance-events.rb +63 -37
- data/bin/check-rds-events.rb +48 -29
- data/bin/check-rds-pending.rb +4 -6
- data/bin/check-rds.rb +15 -2
- data/bin/check-sensu-client.rb +13 -4
- data/bin/check-subnet-ip-consumption.rb +229 -0
- data/bin/handler-ec2_node.rb +29 -13
- data/bin/metrics-emr-steps.rb +1 -1
- data/bin/metrics-sqs.rb +10 -11
- data/lib/sensu-plugins-aws/common.rb +1 -1
- data/lib/sensu-plugins-aws/version.rb +1 -1
- metadata +54 -37
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZjY3ZTk3ODIzODhhNzUwODI1ZmUzM2YzYWUxNDUzMzJlMDUzNWYyNQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 65a658312741eaa7884c4c1c12cad191fa918902
|
4
|
+
data.tar.gz: 79db3d111315f8eeb145ddfefb975851f0c6e3b7
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YWI5NjM0MmZiODU5YTI0NTBlMDA5NWM0Y2I0NzQ1N2FkNzMzZTUzNDgyMDVk
|
11
|
-
MGU2MzJkOGUzMThmODZmYjNlZTg2OTA2M2U3N2EwODQzMjg3MTk=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZDk3YmU4ZmM4OWEyOTRjMmVmNTI1MTc3Mzc4YTAwYTgzMzU4NzM4Y2VmZTQy
|
14
|
-
ZTc3YjNiYjQ3N2JmNGNjMDM4OTNmZmI4ODZlNWUxMzQ1ZWFiMzg4ODM4OTIy
|
15
|
-
MmJiYTg5MTU3MTZlNzA0ODhmNTFjNmE4NzIwMDlhYzlhYmE1MGY=
|
6
|
+
metadata.gz: 72da4039f685bf1ec8f5a95f8fccd88c827a0a0e225089224627334bbf0646cd2c290aee3b3ed5947dac99ecc76aac1bfcaaeab7a2318170540c4908337064fb
|
7
|
+
data.tar.gz: 04324188dc9b85f734b8928c845d6bb4acad5c66e9e8932697395a99d6361f937968f12c66fd06e596f69a64e3efcf75aab3d606b84b318a4efd2aa92fde5a50
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,33 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [3.2.0] - 2016-08-03
|
9
|
+
### Fixed
|
10
|
+
- metrics-emr-steps.rb: fixed typo in variable name (@babsher)
|
11
|
+
- metrics-sqs.rb: --scheme option now works with --prefix (@mool)
|
12
|
+
- check-ecs-service-health.rb:
|
13
|
+
- `service_list` retrieves all records when services not provided through options (@marckysharky)
|
14
|
+
- `service_details` - handles scenario whereby services array is greater than aws limit (10) (@marckysharky)
|
15
|
+
- exit code for tests did not respect rspec exit codes due to autorun feature. (#133 @zbintliff)
|
16
|
+
- syntax error in check-sensu-clients (@sstarcher)
|
17
|
+
- check-rds-pending: Fix uninitialized constant (@obazoud)
|
18
|
+
|
19
|
+
### Added
|
20
|
+
- check-rds.rb: Add support for assuming a role in another account (@oba11)
|
21
|
+
- check-instance-events.rb: Add instance_id option (@Jeppesen-io)
|
22
|
+
- check-sensu-clients.rb: SSL support (@sstarcher)
|
23
|
+
- common.rb: adding support for environment variable AWS_REGION when region is specified as an empty string (@sstarcher)
|
24
|
+
- metrics-sqs.rb: Add support for recording additional per-queue SQS metrics (counts of not-visible and delayed messages) (@paddycarey)
|
25
|
+
- check-subnet-ip-consumption.rb: to check consumption of IP addresses in subnets and alert if consumption exceeds a threshold (@nickjacques)
|
26
|
+
- check-beanstalk-health.rb: Add optional region support
|
27
|
+
- check-rds-events.rb: Added '-r all' region support (@swibowo)
|
28
|
+
- check-instance-events.rb: Added '-r all' region support and description of the event. Minor change to output message (@swibowo)
|
29
|
+
- check-elb-health-sdk.rb: Updated available regions fetch (@swibowo)
|
30
|
+
- handler-ec2_node.rb: Add region support (@runningman84)
|
31
|
+
|
32
|
+
### Changed
|
33
|
+
- Update `aws-sdk` dependency pin to ~> 2.3 (@sstarcher)
|
34
|
+
|
8
35
|
## [3.1.0] - 2016-05-15
|
9
36
|
### Fixed
|
10
37
|
- check-instance-events.rb: Ignore completed instance-stop ec2 events
|
@@ -26,6 +53,7 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
26
53
|
|
27
54
|
### Added
|
28
55
|
- Support for Ruby 2.3
|
56
|
+
- check-elb-health-sdk.rb: Added multi-region support and specify instance tag to display on check output
|
29
57
|
- check-rds.rb: Added check for IOPS
|
30
58
|
|
31
59
|
## [2.4.3] - 2016-04-13
|
@@ -198,7 +226,8 @@ WARNING: This release contains major breaking changes that will impact all user
|
|
198
226
|
### Added
|
199
227
|
- initial release
|
200
228
|
|
201
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/3.
|
229
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/3.2.0...HEAD
|
230
|
+
[3.2.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/3.1.0...3.2.0
|
202
231
|
[3.1.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/3.0.0...3.1.0
|
203
232
|
[3.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.4.3...3.0.0
|
204
233
|
[2.4.3]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.4.2...2.4.3
|
data/README.md
CHANGED
@@ -82,6 +82,8 @@
|
|
82
82
|
|
83
83
|
**check-sqs-messages.rb**
|
84
84
|
|
85
|
+
**check-subnet-ip-consumption**
|
86
|
+
|
85
87
|
**check-vpc-nameservers**
|
86
88
|
|
87
89
|
**check_vpc_vpn.py**
|
@@ -151,6 +153,7 @@
|
|
151
153
|
* /bin/check-ses-limit.rb
|
152
154
|
* /bin/check-ses-statistics.rb
|
153
155
|
* /bin/check-sqs-messages.rb
|
156
|
+
* /bin/check-subnet-ip-consumption.rb
|
154
157
|
* /bin/check-vpc-nameservers.rb
|
155
158
|
* /bin/check_vpc_vpn.py
|
156
159
|
* /bin/check_vpc_vpn.rb
|
@@ -45,6 +45,11 @@ class BeanstalkHealth < Sensu::Plugin::Check::CLI
|
|
45
45
|
boolean: true,
|
46
46
|
default: true
|
47
47
|
|
48
|
+
option :aws_region,
|
49
|
+
short: '-r AWS_REGION',
|
50
|
+
long: '--aws-region REGION',
|
51
|
+
description: 'Optional parameter to specify AWS Region.'
|
52
|
+
|
48
53
|
def env_health
|
49
54
|
@env_health ||= beanstalk_client
|
50
55
|
.describe_environment_health(
|
@@ -54,7 +59,13 @@ class BeanstalkHealth < Sensu::Plugin::Check::CLI
|
|
54
59
|
end
|
55
60
|
|
56
61
|
def beanstalk_client
|
57
|
-
@beanstalk_client ||=
|
62
|
+
@beanstalk_client ||= if config[:aws_region]
|
63
|
+
Aws::ElasticBeanstalk::Client.new(
|
64
|
+
region: config[:aws_region]
|
65
|
+
)
|
66
|
+
else
|
67
|
+
Aws::ElasticBeanstalk::Client.new
|
68
|
+
end
|
58
69
|
end
|
59
70
|
|
60
71
|
def instances_health
|
data/bin/check-ec2-filter.rb
CHANGED
@@ -78,7 +78,7 @@ class EC2Filter < Sensu::Plugin::Check::CLI
|
|
78
78
|
option :compare,
|
79
79
|
description: 'Comparision operator for threshold: equal, not, greater, less',
|
80
80
|
short: '-o OPERATION',
|
81
|
-
long: '--
|
81
|
+
long: '--operator OPERATION',
|
82
82
|
default: 'equal'
|
83
83
|
|
84
84
|
def aws_config
|
@@ -68,11 +68,20 @@ class CheckEcsServiceHealth < Sensu::Plugin::Check::CLI
|
|
68
68
|
# List of requested services or all services registered to the cluster
|
69
69
|
def service_list(cluster = 'default', services = nil)
|
70
70
|
return services.split ',' if services
|
71
|
-
|
71
|
+
collect_services(cluster)
|
72
|
+
end
|
73
|
+
|
74
|
+
def collect_services(cluster = 'default', token: nil)
|
75
|
+
response = ecs_client.list_services(cluster: cluster, next_token: token)
|
76
|
+
services = response.service_arns
|
77
|
+
services.push(*collect_services(cluster, token: response.next_token)) if response.next_token
|
78
|
+
services
|
72
79
|
end
|
73
80
|
|
74
81
|
def service_details(cluster = 'default', services = nil)
|
75
|
-
|
82
|
+
service_list(cluster, services).each_slice(10).to_a.map do |s|
|
83
|
+
ecs_client.describe_services(cluster: cluster, services: s)['services']
|
84
|
+
end.flatten
|
76
85
|
end
|
77
86
|
|
78
87
|
def bucket_service(running_count, desired_count)
|
data/bin/check-elb-health-sdk.rb
CHANGED
@@ -26,8 +26,6 @@
|
|
26
26
|
# for details.
|
27
27
|
|
28
28
|
require 'sensu-plugin/check/cli'
|
29
|
-
require 'net/http'
|
30
|
-
require 'uri'
|
31
29
|
require 'aws-sdk-v1'
|
32
30
|
|
33
31
|
class ELBHealth < Sensu::Plugin::Check::CLI
|
@@ -54,6 +52,11 @@ class ELBHealth < Sensu::Plugin::Check::CLI
|
|
54
52
|
long: '--elb-name ELB_NAME',
|
55
53
|
description: 'The Elastic Load Balancer name of which you want to check the health'
|
56
54
|
|
55
|
+
option :instance_tag,
|
56
|
+
short: '-t',
|
57
|
+
long: '--instance-tag INSTANCE_TAG',
|
58
|
+
description: "Specify instance tag to be included in the check output. E.g. 'Name' tag"
|
59
|
+
|
57
60
|
option :instances,
|
58
61
|
short: '-i INSTANCES',
|
59
62
|
long: '--instances INSTANCES',
|
@@ -79,11 +82,21 @@ class ELBHealth < Sensu::Plugin::Check::CLI
|
|
79
82
|
end
|
80
83
|
|
81
84
|
def elb
|
82
|
-
@elb
|
85
|
+
@elb = AWS::ELB.new aws_config
|
86
|
+
end
|
87
|
+
|
88
|
+
def ec2
|
89
|
+
@ec2 = AWS::EC2::Client.new aws_config
|
90
|
+
end
|
91
|
+
|
92
|
+
def ec2_regions
|
93
|
+
# This is for SDK v2
|
94
|
+
# Aws.partition('aws').regions.map(&:name)
|
95
|
+
|
96
|
+
AWS::EC2.regions.map(&:name)
|
83
97
|
end
|
84
98
|
|
85
99
|
def elbs
|
86
|
-
return @elbs if @elbs
|
87
100
|
@elbs = elb.load_balancers.to_a
|
88
101
|
@elbs.select! { |elb| config[:elb_name].include? elb.name } if config[:elb_name]
|
89
102
|
@elbs
|
@@ -98,7 +111,18 @@ class ELBHealth < Sensu::Plugin::Check::CLI
|
|
98
111
|
end
|
99
112
|
instance_health_hash.each do |instance_health|
|
100
113
|
if instance_health[:state] != 'InService'
|
101
|
-
|
114
|
+
instance_id = instance_health[:instance].id
|
115
|
+
state_message = instance_health[:state]
|
116
|
+
|
117
|
+
if config[:instance_tag]
|
118
|
+
instance = ec2.describe_instances(instance_ids: [instance_id])
|
119
|
+
selected_tag = instance[:reservation_index][instance_id][:instances_set][0][:tag_set].select { |tag| tag[:key] == config[:instance_tag] }
|
120
|
+
unless selected_tag.empty?
|
121
|
+
state_message = "#{selected_tag[0][:value]}::#{instance_health[:state]}"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
unhealthy_instances[instance_id] = state_message
|
102
126
|
end
|
103
127
|
end
|
104
128
|
if unhealthy_instances.empty?
|
@@ -109,17 +133,37 @@ class ELBHealth < Sensu::Plugin::Check::CLI
|
|
109
133
|
end
|
110
134
|
|
111
135
|
def run
|
112
|
-
|
136
|
+
aws_regions = ec2_regions
|
137
|
+
@message = ''
|
113
138
|
critical = false
|
114
|
-
|
115
|
-
|
116
|
-
if
|
117
|
-
|
118
|
-
critical = true
|
139
|
+
|
140
|
+
unless config[:aws_region].casecmp('all') == 0
|
141
|
+
if aws_regions.include? config[:aws_region]
|
142
|
+
aws_regions.clear.push(config[:aws_region])
|
119
143
|
else
|
120
|
-
|
144
|
+
critical 'Invalid region specified!'
|
121
145
|
end
|
122
146
|
end
|
147
|
+
|
148
|
+
aws_regions.each do |r| # Iterate each possible region
|
149
|
+
config[:aws_region] = r
|
150
|
+
region_critical = false
|
151
|
+
@message += (elbs.size > 1 ? config[:aws_region] + ': ' : '')
|
152
|
+
elbs.each do |elb|
|
153
|
+
result = check_health elb
|
154
|
+
if result != 'OK'
|
155
|
+
@message += "#{elb.name} unhealthy => #{result.map { |id, state| '[' + id + '::' + state + ']' }.join(' ')}. "
|
156
|
+
critical = true
|
157
|
+
region_critical = true
|
158
|
+
else
|
159
|
+
@message += "#{elb.name} => healthy. " unless config[:verbose] == false
|
160
|
+
end
|
161
|
+
end
|
162
|
+
if elbs.size > 1 && config[:verbose] != true && region_critical == false
|
163
|
+
@message += 'OK. '
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
123
167
|
if critical
|
124
168
|
if config[:warn_only]
|
125
169
|
warning @message
|
@@ -54,6 +54,13 @@ class CheckInstanceEvents < Sensu::Plugin::Check::CLI
|
|
54
54
|
long: '--use-iam',
|
55
55
|
description: 'Use IAM role authenticiation. Instance must have IAM role assigned for this to work'
|
56
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
|
+
|
57
64
|
option :include_name,
|
58
65
|
short: '-n',
|
59
66
|
long: '--include-name',
|
@@ -66,59 +73,78 @@ class CheckInstanceEvents < Sensu::Plugin::Check::CLI
|
|
66
73
|
region: config[:aws_region] }
|
67
74
|
end
|
68
75
|
|
76
|
+
def ec2_regions
|
77
|
+
# This is for SDK v2
|
78
|
+
# Aws.partition('aws').regions.map(&:name)
|
79
|
+
|
80
|
+
AWS::EC2.regions.map(&:name)
|
81
|
+
end
|
82
|
+
|
69
83
|
def run
|
70
84
|
event_instances = []
|
71
85
|
aws_config = {}
|
72
86
|
|
87
|
+
aws_regions = ec2_regions
|
88
|
+
|
89
|
+
unless config[:aws_region].casecmp('all') == 0
|
90
|
+
if aws_regions.include? config[:aws_region]
|
91
|
+
aws_regions.clear.push(config[:aws_region])
|
92
|
+
else
|
93
|
+
critical 'Invalid region specified!'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
73
97
|
if config[:use_iam_role].nil?
|
74
98
|
aws_config[:access_key_id] = config[:aws_access_key]
|
75
99
|
aws_config[:secret_access_key] = config[:aws_secret_access_key]
|
76
100
|
end
|
77
101
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
# Example:
|
85
|
-
# "events_set": [
|
86
|
-
# {
|
87
|
-
# "code": "system-reboot",
|
88
|
-
# "description": "[Completed] Scheduled reboot",
|
89
|
-
# "not_before": "2015-01-05 12:00:00 UTC",
|
90
|
-
# "not_after": "2015-01-05 18:00:00 UTC"
|
91
|
-
# }
|
92
|
-
# ]
|
93
|
-
useful_events =
|
94
|
-
i[:events_set].reject { |x| (x[:code] == 'system-reboot' || x[:code] == 'instance-stop' || x[:code] == 'system-maintenance') && (x[:description] =~ /\[Completed\]/ || x[:description] =~ /\[Canceled\]/) }
|
95
|
-
unless useful_events.empty?
|
96
|
-
event_instances << i[:instance_id]
|
102
|
+
aws_regions.each do |r| # Iterate each possible region
|
103
|
+
ec2 = AWS::EC2::Client.new(aws_config.merge!(region: r))
|
104
|
+
begin
|
105
|
+
describe_instance_options = {}
|
106
|
+
if config[:instance_id].any?
|
107
|
+
describe_instance_options = describe_instance_options.merge(instance_ids: config[:instance_id])
|
97
108
|
end
|
98
|
-
end
|
99
|
-
rescue => e
|
100
|
-
unknown "An error occurred processing AWS EC2 API: #{e.message}"
|
101
|
-
end
|
102
109
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
#
|
110
|
-
|
111
|
-
|
112
|
-
|
110
|
+
ec2.describe_instance_status(describe_instance_options)[:instance_status_set].each do |i|
|
111
|
+
next if i[:events_set].empty?
|
112
|
+
|
113
|
+
# Exclude completed reboots since the events API appearently returns these even after they have been completed:
|
114
|
+
# Example:
|
115
|
+
# "events_set": [
|
116
|
+
# {
|
117
|
+
# "code": "system-reboot",
|
118
|
+
# "description": "[Completed] Scheduled reboot",
|
119
|
+
# "not_before": "2015-01-05 12:00:00 UTC",
|
120
|
+
# "not_after": "2015-01-05 18:00:00 UTC"
|
121
|
+
# }
|
122
|
+
# ]
|
123
|
+
useful_events =
|
124
|
+
i[:events_set].reject { |x| (x[:code] =~ /system-reboot|instance-stop|system-maintenance/) && (x[:description] =~ /\[Completed\]|\[Canceled\]/) }
|
125
|
+
|
126
|
+
unless useful_events.empty?
|
127
|
+
if config[:include_name]
|
128
|
+
name = ''
|
129
|
+
begin
|
130
|
+
instance_desc = ec2.describe_instances(instance_ids: [i[:instance_id]])
|
131
|
+
name = instance_desc[:reservation_index][i[:instance_id]][:instances_set][0][:tag_set].select { |tag| tag[:key] == 'Name' }[0][:value]
|
132
|
+
rescue => e
|
133
|
+
puts "Issue getting instance details for #{i[:instance_id]} (#{r}). Exception = #{e}"
|
134
|
+
end
|
135
|
+
event_instances << "#{name} (#{i[:instance_id]} #{r}) (#{i[:events_set][0][:code]}) #{i[:events_set][0][:description]}"
|
136
|
+
else
|
137
|
+
event_instances << "#{i[:instance_id]} (#{r}) (#{i[:events_set][0][:code]}) #{i[:events_set][0][:description]}"
|
138
|
+
end
|
139
|
+
end
|
113
140
|
end
|
114
|
-
|
115
|
-
|
141
|
+
rescue => e
|
142
|
+
unknown "An error occurred processing AWS EC2 API (#{r}): #{e.message}"
|
116
143
|
end
|
117
|
-
event_instances = event_instances_with_names
|
118
144
|
end
|
119
145
|
|
120
146
|
if event_instances.count > 0
|
121
|
-
critical("#{event_instances.count}
|
147
|
+
critical("#{event_instances.count} instance#{event_instances.count > 1 ? 's have' : ' has'} upcoming scheduled events: #{event_instances.join(',')}")
|
122
148
|
else
|
123
149
|
ok
|
124
150
|
end
|
data/bin/check-rds-events.rb
CHANGED
@@ -73,6 +73,13 @@ class CheckRDSEvents < Sensu::Plugin::Check::CLI
|
|
73
73
|
region: config[:aws_region] }
|
74
74
|
end
|
75
75
|
|
76
|
+
def rds_regions
|
77
|
+
# This is for SDK v2
|
78
|
+
# Aws.partition('aws').regions.map(&:name)
|
79
|
+
|
80
|
+
AWS::RDS.regions.map(&:name)
|
81
|
+
end
|
82
|
+
|
76
83
|
def run
|
77
84
|
clusters = maint_clusters
|
78
85
|
if clusters.empty?
|
@@ -83,44 +90,56 @@ class CheckRDSEvents < Sensu::Plugin::Check::CLI
|
|
83
90
|
end
|
84
91
|
|
85
92
|
def maint_clusters
|
86
|
-
|
93
|
+
maint_clusters = []
|
94
|
+
aws_regions = rds_regions
|
87
95
|
|
88
|
-
|
89
|
-
if
|
90
|
-
|
91
|
-
if db_instance.nil? || db_instance.empty?
|
92
|
-
unknown "#{config[:db_instance_id]} instance not found"
|
93
|
-
else
|
94
|
-
clusters = [config[:db_instance_id]]
|
95
|
-
end
|
96
|
+
unless config[:aws_region].casecmp('all') == 0
|
97
|
+
if aws_regions.include? config[:aws_region]
|
98
|
+
aws_regions.clear.push(config[:aws_region])
|
96
99
|
else
|
97
|
-
|
98
|
-
clusters = rds.describe_db_instances[:db_instances].map { |db| db[:db_instance_identifier] }
|
100
|
+
critical 'Invalid region specified!'
|
99
101
|
end
|
102
|
+
end
|
100
103
|
|
101
|
-
|
104
|
+
aws_regions.each do |r|
|
105
|
+
rds = AWS::RDS::Client.new aws_config.merge!(region: r)
|
102
106
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
107
|
+
begin
|
108
|
+
if !config[:db_instance_id].nil? && !config[:db_instance_id].empty?
|
109
|
+
db_instance = rds.describe_db_instances(db_instance_identifier: config[:db_instance_id])
|
110
|
+
if db_instance.nil? || db_instance.empty?
|
111
|
+
unknown "#{config[:db_instance_id]} instance not found"
|
112
|
+
else
|
113
|
+
clusters = [config[:db_instance_id]]
|
114
|
+
end
|
115
|
+
else
|
116
|
+
# fetch all clusters identifiers
|
117
|
+
clusters = rds.describe_db_instances[:db_instances].map { |db| db[:db_instance_identifier] }
|
118
|
+
end
|
108
119
|
|
109
|
-
#
|
110
|
-
#
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
# you can add more filters to skip more events.
|
120
|
+
# fetch the last 15 minutes of events for each cluster
|
121
|
+
# that way, we're only spammed with persistent notifications that we'd care about.
|
122
|
+
clusters.each do |cluster_name|
|
123
|
+
events_record = rds.describe_events(start_time: (Time.now - 900).iso8601, source_type: 'db-instance', source_identifier: cluster_name)
|
124
|
+
next if events_record[:events].empty?
|
115
125
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
126
|
+
# we will need to filter out non-disruptive/basic operation events.
|
127
|
+
# ie. the regular backup operations
|
128
|
+
next if events_record[:events][-1][:message] =~ /Backing up DB instance|Finished DB Instance backup|Restored from snapshot/
|
129
|
+
# ie. Replication resumed
|
130
|
+
next if events_record[:events][-1][:message] =~ /Replication for the Read Replica resumed/
|
131
|
+
# you can add more filters to skip more events.
|
132
|
+
|
133
|
+
# draft the messages
|
134
|
+
cluster_name_long = "#{cluster_name} (#{r}) #{events_record[:events][-1][:message]}"
|
135
|
+
maint_clusters.push(cluster_name_long)
|
136
|
+
end
|
120
137
|
|
121
|
-
|
122
|
-
|
138
|
+
rescue => e
|
139
|
+
unknown "An error occurred processing AWS RDS API (#{r}): #{e.message}"
|
140
|
+
end
|
123
141
|
end
|
142
|
+
|
124
143
|
maint_clusters
|
125
144
|
end
|
126
145
|
end
|
data/bin/check-rds-pending.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# check-rds-
|
3
|
+
# check-rds-pending
|
4
4
|
#
|
5
5
|
#
|
6
6
|
# DESCRIPTION:
|
7
|
-
# This plugin checks rds clusters for
|
8
|
-
# Due to the number of events types on RDS clusters the check searches for
|
9
|
-
# events containing the text string 'has started' or 'is being'. These events all have
|
10
|
-
# accompanying completiion events and are impacting events
|
7
|
+
# This plugin checks rds clusters for pending maintenance action.
|
11
8
|
#
|
12
9
|
# OUTPUT:
|
13
10
|
# plain-text
|
@@ -20,7 +17,7 @@
|
|
20
17
|
# gem: sensu-plugin
|
21
18
|
#
|
22
19
|
# USAGE:
|
23
|
-
# ./check-rds-
|
20
|
+
# ./check-rds-pending.rb -r ${you_region}
|
24
21
|
#
|
25
22
|
# NOTES:
|
26
23
|
#
|
@@ -31,6 +28,7 @@
|
|
31
28
|
#
|
32
29
|
|
33
30
|
require 'sensu-plugin/check/cli'
|
31
|
+
require 'sensu-plugins-aws'
|
34
32
|
require 'aws-sdk'
|
35
33
|
|
36
34
|
class CheckRDSEvents < Sensu::Plugin::Check::CLI
|
data/bin/check-rds.rb
CHANGED
@@ -70,6 +70,11 @@ class CheckRDS < Sensu::Plugin::Check::CLI
|
|
70
70
|
description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
|
71
71
|
default: ENV['AWS_SECRET_KEY']
|
72
72
|
|
73
|
+
option :role_arn,
|
74
|
+
long: '--role-arn ROLE_ARN',
|
75
|
+
description: 'AWS role arn of the role of the third party account to switch to',
|
76
|
+
default: false
|
77
|
+
|
73
78
|
option :aws_region,
|
74
79
|
short: '-r AWS_REGION',
|
75
80
|
long: '--aws-region REGION',
|
@@ -127,12 +132,20 @@ class CheckRDS < Sensu::Plugin::Check::CLI
|
|
127
132
|
region: config[:aws_region] }
|
128
133
|
end
|
129
134
|
|
135
|
+
def role_credentials
|
136
|
+
@role_credentials = Aws::AssumeRoleCredentials.new(
|
137
|
+
client: Aws::STS::Client.new(aws_config),
|
138
|
+
role_arn: config[:role_arn],
|
139
|
+
role_session_name: "role@#{Time.now.to_i}"
|
140
|
+
)
|
141
|
+
end
|
142
|
+
|
130
143
|
def rds
|
131
|
-
@rds ||= Aws::RDS::Client.new aws_config
|
144
|
+
@rds ||= config[:role_arn] ? Aws::RDS::Client.new(credentials: role_credentials, region: aws_config[:region]) : Aws::RDS::Client.new(aws_config)
|
132
145
|
end
|
133
146
|
|
134
147
|
def cloud_watch
|
135
|
-
@cloud_watch ||= Aws::CloudWatch::Client.new aws_config
|
148
|
+
@cloud_watch ||= config[:role_arn] ? Aws::CloudWatch::Client.new(credentials: role_credentials, region: aws_config[:region]) : Aws::CloudWatch::Client.new(aws_config)
|
136
149
|
end
|
137
150
|
|
138
151
|
def find_db_instance(id)
|
data/bin/check-sensu-client.rb
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
require 'sensu-plugins-aws'
|
34
34
|
require 'sensu-plugin/check/cli'
|
35
35
|
require 'aws-sdk'
|
36
|
-
require '
|
36
|
+
require 'rest-client'
|
37
37
|
require 'json'
|
38
38
|
|
39
39
|
class CheckSensuClient < Sensu::Plugin::Check::CLI
|
@@ -51,6 +51,12 @@ class CheckSensuClient < Sensu::Plugin::Check::CLI
|
|
51
51
|
description: 'Sensu host to query',
|
52
52
|
default: 'sensu'
|
53
53
|
|
54
|
+
option :insecure,
|
55
|
+
short: '-k',
|
56
|
+
boolean: true,
|
57
|
+
description: 'Enabling insecure connections',
|
58
|
+
default: false
|
59
|
+
|
54
60
|
option :sensu_port,
|
55
61
|
short: '-p SENSU_PORT',
|
56
62
|
long: '--port SENSU_PORT',
|
@@ -97,7 +103,7 @@ class CheckSensuClient < Sensu::Plugin::Check::CLI
|
|
97
103
|
end.reduce(:merge)
|
98
104
|
filter_list.delete(nil)
|
99
105
|
filter_list.each { |x, y| filter_list[x] = y.strip.gsub(/[\[\]]/, '') }
|
100
|
-
client = Aws::EC2::Client.new
|
106
|
+
client = Aws::EC2::Client.new
|
101
107
|
|
102
108
|
parsed_filter = Filter.parse(config[:filter])
|
103
109
|
|
@@ -162,8 +168,11 @@ class CheckSensuClient < Sensu::Plugin::Check::CLI
|
|
162
168
|
end
|
163
169
|
|
164
170
|
def client_check
|
165
|
-
|
166
|
-
|
171
|
+
verify_mode = OpenSSL::SSL::VERIFY_PEER
|
172
|
+
verify_mode = OpenSSL::SSL::VERIFY_NONE if config[:insecure]
|
173
|
+
request = RestClient::Resource.new("#{config[:sensu_host]}:#{config[:sensu_port]}/clients",
|
174
|
+
verify_ssl: verify_mode)
|
175
|
+
response = JSON.parse(request.get)
|
167
176
|
|
168
177
|
clients = Set.new
|
169
178
|
response.each do |client|
|
@@ -0,0 +1,229 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-subnet-ip-consumption
|
4
|
+
#
|
5
|
+
#
|
6
|
+
# DESCRIPTION:
|
7
|
+
# This plugin uses the EC2 API to determine if any subnet in a given region
|
8
|
+
# has consumed IP addresses such that the consumption exceeds a user-specified threshold.
|
9
|
+
# This plugin additionally uses the IAM API to resolve the account alias,
|
10
|
+
# if the user uses the -s/--show-account-alias flag.
|
11
|
+
#
|
12
|
+
# OUTPUT:
|
13
|
+
# plain-text
|
14
|
+
#
|
15
|
+
# PLATFORMS:
|
16
|
+
# Linux
|
17
|
+
#
|
18
|
+
# DEPENDENCIES:
|
19
|
+
# gem: aws-sdk
|
20
|
+
# gem: sensu-plugin
|
21
|
+
# gem: sensu-plugins-aws
|
22
|
+
#
|
23
|
+
# USAGE:
|
24
|
+
# ./check-subnet-ip-consumption.rb -a <access key> -k <secret key> -r <region> -t <integer percentage>
|
25
|
+
#
|
26
|
+
# NOTES:
|
27
|
+
# Special thanks to Garrett Kuchta and Antonio Beyah for their assistance.
|
28
|
+
#
|
29
|
+
# LICENSE:
|
30
|
+
# Nick Jacques <Nick.Jacques@target.com>
|
31
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
32
|
+
# for details.
|
33
|
+
|
34
|
+
require 'sensu-plugin/check/cli'
|
35
|
+
require 'sensu-plugins-aws'
|
36
|
+
require 'aws-sdk'
|
37
|
+
|
38
|
+
class CheckSubnetIpConsumption < 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 :alert_threshold,
|
48
|
+
short: '-t <threshold percentage>',
|
49
|
+
long: '--threshold <threshold percentage>',
|
50
|
+
proc: proc { |a| a.to_i },
|
51
|
+
default: 85,
|
52
|
+
in: (0..100).to_a,
|
53
|
+
description: 'Threshold (in percent) of consumed IP addresses (per subnet) to alert on'
|
54
|
+
|
55
|
+
option :show_friendly_names,
|
56
|
+
short: '-f',
|
57
|
+
long: '--show-friendly-names',
|
58
|
+
boolean: true,
|
59
|
+
default: false,
|
60
|
+
description: 'Show friendly names (using the Name tag) for AWS objects such as subnets or VPCs'
|
61
|
+
|
62
|
+
option :show_account_alias,
|
63
|
+
short: '-s',
|
64
|
+
long: '--show-account-alias',
|
65
|
+
boolean: true,
|
66
|
+
default: false,
|
67
|
+
description: 'Show the account alias in the alert output. Requires IAM read privileges.'
|
68
|
+
|
69
|
+
option :verbosity,
|
70
|
+
short: '-v <level>',
|
71
|
+
long: '--verbosity <level>',
|
72
|
+
proc: proc { |a| a.to_i },
|
73
|
+
in: (0..2).to_a,
|
74
|
+
default: 0,
|
75
|
+
description: 'Manipulate the verbosity of the alert output. Valid options are 0, 1, and 2 (from least to most verbose). Default is 0.'
|
76
|
+
|
77
|
+
def iam_client
|
78
|
+
@iam_client ||= Aws::IAM::Client.new
|
79
|
+
end
|
80
|
+
|
81
|
+
def ec2_client
|
82
|
+
@ec2_client ||= Aws::EC2::Client.new
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns the alias of the AWS account (if there is one), "<no name>" (if there is not), or nil if -s/--show-account-alias is not used.
|
86
|
+
def account_alias
|
87
|
+
# Do not execute IAM API call unless the -s/--show_account_alias flag is specified
|
88
|
+
# (to prevent excess API calls *and* errors if IAM rights are not allowed)
|
89
|
+
return nil unless config[:show_account_alias]
|
90
|
+
|
91
|
+
begin
|
92
|
+
iam_account_alias = iam_client.list_account_aliases[:account_aliases].first
|
93
|
+
|
94
|
+
return '<no alias>' if iam_account_alias.empty? || iam_account_alias.nil?
|
95
|
+
return iam_account_alias
|
96
|
+
rescue => e
|
97
|
+
unknown "An error occured while using AWS IAM to collect the account alias: #{e.message}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Returns the value of the Name tag (if there is one) or "<no name>" (if there is not). Used with VPC and subnet objects.
|
102
|
+
def extract_name_tag(tags)
|
103
|
+
# Find the 'Name' key in the tags object and extract it. If the key isn't found, we get nil instead.
|
104
|
+
name_tag = tags.find { |tag| tag.key == 'Name' }
|
105
|
+
# If extracting the key/value was successful...
|
106
|
+
if name_tag
|
107
|
+
# ...extract the value (if there is one), or return <no name>
|
108
|
+
!name_tag[:value].empty? ? name_tag[:value] : '<no name>'
|
109
|
+
else
|
110
|
+
# Otherwise, there's not a Name key, and thus the object has no name.
|
111
|
+
'<no name>'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Returns the subnet's friendly name if -f/--show-friendly-names is used, otherwise returns the ID
|
116
|
+
def display_subnet(alert)
|
117
|
+
return alert[:subnet_name] if config[:show_friendly_names]
|
118
|
+
alert[:subnet_id]
|
119
|
+
end
|
120
|
+
|
121
|
+
# Returns the VPC's friendly name if -f/--show-friendly-names is used, otherwise returns the ID
|
122
|
+
def display_vpc(alert)
|
123
|
+
return alert[:vpc_friendly_name] if config[:show_friendly_names]
|
124
|
+
alert[:subnet_vpc_id]
|
125
|
+
end
|
126
|
+
|
127
|
+
def run
|
128
|
+
# Subnets that meet the threshold criteria will store info hashes in this array
|
129
|
+
consumption_alert = []
|
130
|
+
|
131
|
+
begin
|
132
|
+
subnets = ec2_client.describe_subnets[:subnets]
|
133
|
+
|
134
|
+
subnets.each do |subnet|
|
135
|
+
# subnet.cidr_block contains '0.0.0.0/0' notation. We want the mask number after the slash.
|
136
|
+
subnet_netblock = subnet.cidr_block.split('/')[1].to_i
|
137
|
+
# Subtract the mask number from 32 and use the result as the exponent of 2 to get the number of possible addresses in the netblock.
|
138
|
+
# Then, subtract 5 from that number. Rationale: http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html#VPC_Sizing
|
139
|
+
# AWS reserves the first four addresses and the last address in any netblock.
|
140
|
+
subnet_total_capacity = (2**(32 - subnet_netblock)) - 5
|
141
|
+
# Determine how many IP addresses have been consumed
|
142
|
+
subnet_consumed_capacity = (subnet_total_capacity - subnet.available_ip_address_count)
|
143
|
+
# Divide consumed IPs by total IPs to get percentage. Multiply by 100 and round to get integer percents.
|
144
|
+
subnet_consumed_pct = ((subnet_consumed_capacity.to_f / subnet_total_capacity.to_f) * 100).round(0)
|
145
|
+
|
146
|
+
# Get the subnet's friendly name
|
147
|
+
subnet_name_tag = extract_name_tag subnet[:tags]
|
148
|
+
# Only get the VPC friendly names if explicitly asked for (otherwise this is a useless API hit)
|
149
|
+
if config[:show_friendly_names]
|
150
|
+
vpc = ec2_client.describe_vpcs(vpc_ids: [subnet.vpc_id])[:vpcs].first
|
151
|
+
vpc_friendly_name = extract_name_tag vpc[:tags]
|
152
|
+
end
|
153
|
+
|
154
|
+
# Test if the subnet consumption % meets or exceeds the threshold %
|
155
|
+
if subnet_consumed_pct >= config[:alert_threshold]
|
156
|
+
# Add a hash containing subnet info to the consumption_alert array
|
157
|
+
consumption_alert.push(subnet_id: subnet.subnet_id,
|
158
|
+
subnet_name: subnet_name_tag,
|
159
|
+
subnet_consumed_pct: subnet_consumed_pct,
|
160
|
+
subnet_vpc_id: subnet.vpc_id,
|
161
|
+
subnet_consumed_capacity: subnet_consumed_capacity,
|
162
|
+
subnet_total_capacity: subnet_total_capacity,
|
163
|
+
subnet_az: subnet[:availability_zone],
|
164
|
+
cidr_block: subnet[:cidr_block],
|
165
|
+
vpc_friendly_name: vpc_friendly_name)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
rescue => e
|
169
|
+
unknown "An error occurred processing AWS EC2: #{e.message}"
|
170
|
+
end
|
171
|
+
|
172
|
+
# Process any alerts that might've been generated.
|
173
|
+
if consumption_alert.empty?
|
174
|
+
ok
|
175
|
+
else
|
176
|
+
# Compose alert messages at the configured verbosity
|
177
|
+
alert_msg = []
|
178
|
+
|
179
|
+
verbosity0 = '%{subnet} at %{percent}%% [%{vpc}]'
|
180
|
+
verbosity1 = '%{subnet} at %{percent}%% (%{consumed}/%{total}) [%{vpc}]'
|
181
|
+
verbosity2 = '%{subnet} (%{cidr} in %{az}) at %{percent}%% (%{consumed}/%{total}) [%{vpc}]'
|
182
|
+
|
183
|
+
case config[:verbosity]
|
184
|
+
when 0
|
185
|
+
consumption_alert.each do |alert|
|
186
|
+
alert_msg.push(verbosity0 % { subnet: (display_subnet alert).to_s,
|
187
|
+
percent: alert[:subnet_consumed_pct],
|
188
|
+
vpc: (display_vpc alert).to_s })
|
189
|
+
end
|
190
|
+
when 1
|
191
|
+
consumption_alert.each do |alert|
|
192
|
+
alert_msg.push(verbosity1 % { subnet: (display_subnet alert).to_s,
|
193
|
+
percent: alert[:subnet_consumed_pct],
|
194
|
+
consumed: alert[:subnet_consumed_capacity],
|
195
|
+
total: alert[:subnet_total_capacity],
|
196
|
+
vpc: (display_vpc alert).to_s })
|
197
|
+
end
|
198
|
+
when 2
|
199
|
+
consumption_alert.each do |alert|
|
200
|
+
alert_msg.push(verbosity2 % { subnet: (display_subnet alert).to_s,
|
201
|
+
cidr: alert[:cidr_block],
|
202
|
+
az: alert[:subnet_az],
|
203
|
+
percent: alert[:subnet_consumed_pct],
|
204
|
+
consumed: alert[:subnet_consumed_capacity],
|
205
|
+
total: alert[:subnet_total_capacity],
|
206
|
+
vpc: (display_vpc alert).to_s })
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
# Throw critical alert with optional account alias display
|
211
|
+
alert_prefix = '%{count} subnets in %{region} exceeding %{threshold}%% IP consumption threshold: %{alerts}'
|
212
|
+
alert_prefix_with_alias = '%{count} subnets in %{alias} (%{region}) exceeding %{threshold}%% IP consumption threshold: %{alerts}'
|
213
|
+
|
214
|
+
case config[:show_account_alias]
|
215
|
+
when true
|
216
|
+
critical(alert_prefix_with_alias % { count: alert_msg.length,
|
217
|
+
alias: account_alias,
|
218
|
+
region: config[:aws_region],
|
219
|
+
threshold: config[:alert_threshold],
|
220
|
+
alerts: alert_msg.join(', ') })
|
221
|
+
when false
|
222
|
+
critical(alert_prefix % { count: alert_msg.length,
|
223
|
+
region: config[:aws_region],
|
224
|
+
threshold: config[:alert_threshold],
|
225
|
+
alerts: alert_msg.join(', ') })
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
data/bin/handler-ec2_node.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
3
|
# CHANGELOG:
|
4
|
+
# * 0.8.0:
|
5
|
+
# - Added support to use ec2_region from client definition
|
4
6
|
# * 0.7.0:
|
5
7
|
# - Added method instance_id to check in client config section
|
6
|
-
#
|
7
|
-
# - Update to new API event naming and simplifying ec2_node_should_be_deleted method and fixing
|
8
|
+
# - Update to new API event naming and simplifying ec2_node_should_be_deleted method and fixing
|
8
9
|
# match that will work with any user state defined.
|
9
10
|
# * 0.6.0:
|
10
11
|
# - Fixed ec2_node_should_be_deleted to account for an empty insances array
|
@@ -61,7 +62,28 @@
|
|
61
62
|
# handler to suit your needs.
|
62
63
|
#
|
63
64
|
#
|
64
|
-
#
|
65
|
+
# A Sensu Client configuration using the ec2_region attribute:
|
66
|
+
# {
|
67
|
+
# "client": {
|
68
|
+
# "name": "i-424242",
|
69
|
+
# "address": "127.0.0.1",
|
70
|
+
# "ec2_region": "eu-west-1",
|
71
|
+
# "subscriptions": ["all"]
|
72
|
+
# }
|
73
|
+
# }
|
74
|
+
# or embeded in the ec2 block
|
75
|
+
# {
|
76
|
+
# "client": {
|
77
|
+
# "name": "i-424242",
|
78
|
+
# "address": "127.0.0.1",
|
79
|
+
# "ec2" : {
|
80
|
+
# "region": "eu-west-1"
|
81
|
+
# },
|
82
|
+
# "subscriptions": ["all"]
|
83
|
+
# }
|
84
|
+
# }
|
85
|
+
#
|
86
|
+
# Or a Sensu Server configuration snippet:
|
65
87
|
# {
|
66
88
|
# "aws": {
|
67
89
|
# "access_key": "adsafdafda",
|
@@ -78,7 +100,7 @@
|
|
78
100
|
# If none of the settings are found it will then attempt to
|
79
101
|
# generate temporary credentials from the IAM instance profile
|
80
102
|
#
|
81
|
-
# If region is not specified in either of the above
|
103
|
+
# If region is not specified in either of the above 3 mechanisms
|
82
104
|
# we will make a request for the EC2 instances current region.
|
83
105
|
#
|
84
106
|
# To use, you can set it as the keepalive handler for a client:
|
@@ -153,14 +175,6 @@ class Ec2Node < Sensu::Handler
|
|
153
175
|
end
|
154
176
|
|
155
177
|
def instance_id
|
156
|
-
if @event['client'].key?('aws') && @event['client']['aws'].key?('instance_id')
|
157
|
-
@event['client']['aws']['instance_id']
|
158
|
-
else
|
159
|
-
@event['client']['name']
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
def instance_name
|
164
178
|
@event['client']['name']
|
165
179
|
end
|
166
180
|
|
@@ -198,7 +212,9 @@ class Ec2Node < Sensu::Handler
|
|
198
212
|
def region
|
199
213
|
@region ||= begin
|
200
214
|
region_check = ENV['EC2_REGION']
|
201
|
-
region_check = settings['aws']['region'] if settings.key?
|
215
|
+
region_check = settings['aws']['region'] if settings.key?('aws')
|
216
|
+
region_check = @event['client']['ec2_region'] if @event['client'].key?('ec2_region')
|
217
|
+
region_check = @event['client']['ec2']['region'] if @event['client'].key?('ec2') && @event['client']['ec2'].key?('region')
|
202
218
|
if region_check.nil? || region_check.empty?
|
203
219
|
region_check = Net::HTTP.get(URI('http://169.254.169.254/latest/meta-data/placement/availability-zone'))
|
204
220
|
matches = /(\w+\-\w+\-\d+)/.match(region_check)
|
data/bin/metrics-emr-steps.rb
CHANGED
@@ -74,7 +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.' +
|
77
|
+
output config[:scheme] + '.' + safe_name + '.id.' + cluster.id
|
78
78
|
STATUS.each_entry { |status| output config[:scheme] + '.' + safe_name + '.step.' + status, data[status] }
|
79
79
|
end
|
80
80
|
ok
|
data/bin/metrics-sqs.rb
CHANGED
@@ -74,7 +74,14 @@ class SQSMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def scheme(queue_name)
|
77
|
-
|
77
|
+
scheme = config[:scheme].empty? ? 'aws.sqs.queue' : config[:scheme]
|
78
|
+
"#{scheme}.#{queue_name.tr('-', '_')}.message_count"
|
79
|
+
end
|
80
|
+
|
81
|
+
def record_queue_metrics(q_name, q)
|
82
|
+
output scheme(q_name), q.approximate_number_of_messages
|
83
|
+
output "#{scheme(q_name)}.delayed", q.approximate_number_of_messages_delayed
|
84
|
+
output "#{scheme(q_name)}.not_visible", q.approximate_number_of_messages_not_visible
|
78
85
|
end
|
79
86
|
|
80
87
|
def run
|
@@ -86,18 +93,10 @@ class SQSMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
86
93
|
critical 'Error, either QUEUE or PREFIX must be specified'
|
87
94
|
end
|
88
95
|
|
89
|
-
|
90
|
-
scheme config[:queue]
|
91
|
-
else
|
92
|
-
config[:scheme]
|
93
|
-
end
|
94
|
-
|
95
|
-
messages = sqs.queues.named(config[:queue]).approximate_number_of_messages
|
96
|
-
output scheme, messages
|
96
|
+
record_queue_metrics(config[:queue], sqs.queues.named(config[:queue]))
|
97
97
|
else
|
98
98
|
sqs.queues.with_prefix(config[:prefix]).each do |q|
|
99
|
-
|
100
|
-
output scheme(queue_name), q.approximate_number_of_messages
|
99
|
+
record_queue_metrics(q.arn.split(':').last, q)
|
101
100
|
end
|
102
101
|
end
|
103
102
|
rescue => e
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: '2.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: aws-sdk-v1
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: sensu-plugin
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.3'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: erubis
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,138 +94,153 @@ dependencies:
|
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 2.7.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rest-client
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.8.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.8.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: bundler
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- - ~>
|
115
|
+
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '1.7'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- - ~>
|
122
|
+
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '1.7'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: codeclimate-test-reporter
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- - ~>
|
129
|
+
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
131
|
version: '0.4'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- - ~>
|
136
|
+
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0.4'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: github-markup
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
|
-
- - ~>
|
143
|
+
- - "~>"
|
130
144
|
- !ruby/object:Gem::Version
|
131
145
|
version: '1.3'
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
|
-
- - ~>
|
150
|
+
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '1.3'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: pry
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
|
-
- - ~>
|
157
|
+
- - "~>"
|
144
158
|
- !ruby/object:Gem::Version
|
145
159
|
version: '0.10'
|
146
160
|
type: :development
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
|
-
- - ~>
|
164
|
+
- - "~>"
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0.10'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: rake
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
|
-
- - ~>
|
171
|
+
- - "~>"
|
158
172
|
- !ruby/object:Gem::Version
|
159
173
|
version: '10.5'
|
160
174
|
type: :development
|
161
175
|
prerelease: false
|
162
176
|
version_requirements: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
|
-
- - ~>
|
178
|
+
- - "~>"
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '10.5'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: redcarpet
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
|
-
- - ~>
|
185
|
+
- - "~>"
|
172
186
|
- !ruby/object:Gem::Version
|
173
187
|
version: '3.2'
|
174
188
|
type: :development
|
175
189
|
prerelease: false
|
176
190
|
version_requirements: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
|
-
- - ~>
|
192
|
+
- - "~>"
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: '3.2'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: rubocop
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
184
198
|
requirements:
|
185
|
-
- - ~>
|
199
|
+
- - "~>"
|
186
200
|
- !ruby/object:Gem::Version
|
187
201
|
version: 0.40.0
|
188
202
|
type: :development
|
189
203
|
prerelease: false
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
|
-
- - ~>
|
206
|
+
- - "~>"
|
193
207
|
- !ruby/object:Gem::Version
|
194
208
|
version: 0.40.0
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
name: rspec
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
198
212
|
requirements:
|
199
|
-
- - ~>
|
213
|
+
- - "~>"
|
200
214
|
- !ruby/object:Gem::Version
|
201
215
|
version: '3.4'
|
202
216
|
type: :development
|
203
217
|
prerelease: false
|
204
218
|
version_requirements: !ruby/object:Gem::Requirement
|
205
219
|
requirements:
|
206
|
-
- - ~>
|
220
|
+
- - "~>"
|
207
221
|
- !ruby/object:Gem::Version
|
208
222
|
version: '3.4'
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
224
|
name: yard
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
212
226
|
requirements:
|
213
|
-
- - ~>
|
227
|
+
- - "~>"
|
214
228
|
- !ruby/object:Gem::Version
|
215
229
|
version: '0.8'
|
216
230
|
type: :development
|
217
231
|
prerelease: false
|
218
232
|
version_requirements: !ruby/object:Gem::Requirement
|
219
233
|
requirements:
|
220
|
-
- - ~>
|
234
|
+
- - "~>"
|
221
235
|
- !ruby/object:Gem::Version
|
222
236
|
version: '0.8'
|
223
|
-
description:
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
237
|
+
description: |-
|
238
|
+
This plugin provides native AWS instrumentation
|
239
|
+
for monitoring and metrics collection, including:
|
240
|
+
health and metrics for various AWS services, such
|
241
|
+
as EC2, RDS, ELB, and more, as well as handlers
|
242
|
+
for EC2, SES, and SNS.
|
243
|
+
email: "<sensu-users@googlegroups.com>"
|
229
244
|
executables:
|
230
245
|
- check-autoscaling-cpucredits.rb
|
231
246
|
- check-beanstalk-elb-metric.rb
|
@@ -270,6 +285,7 @@ executables:
|
|
270
285
|
- check-ses-statistics.rb
|
271
286
|
- check-sns-subscriptions.rb
|
272
287
|
- check-sqs-messages.rb
|
288
|
+
- check-subnet-ip-consumption.rb
|
273
289
|
- check-trustedadvisor-service-limits.rb
|
274
290
|
- check-vpc-nameservers.rb
|
275
291
|
- check-vpc-vpn.rb
|
@@ -336,6 +352,7 @@ files:
|
|
336
352
|
- bin/check-ses-statistics.rb
|
337
353
|
- bin/check-sns-subscriptions.rb
|
338
354
|
- bin/check-sqs-messages.rb
|
355
|
+
- bin/check-subnet-ip-consumption.rb
|
339
356
|
- bin/check-trustedadvisor-service-limits.rb
|
340
357
|
- bin/check-vpc-nameservers.rb
|
341
358
|
- bin/check-vpc-vpn.rb
|
@@ -375,17 +392,17 @@ require_paths:
|
|
375
392
|
- lib
|
376
393
|
required_ruby_version: !ruby/object:Gem::Requirement
|
377
394
|
requirements:
|
378
|
-
- -
|
395
|
+
- - ">="
|
379
396
|
- !ruby/object:Gem::Version
|
380
397
|
version: 2.1.0
|
381
398
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
382
399
|
requirements:
|
383
|
-
- -
|
400
|
+
- - ">="
|
384
401
|
- !ruby/object:Gem::Version
|
385
402
|
version: '0'
|
386
403
|
requirements: []
|
387
404
|
rubyforge_project:
|
388
|
-
rubygems_version: 2.
|
405
|
+
rubygems_version: 2.5.1
|
389
406
|
signing_key:
|
390
407
|
specification_version: 4
|
391
408
|
summary: Sensu plugins for working with an AWS environment
|