sensu-plugins-aws 0.0.1.alpha.2 → 0.0.1
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 +4 -4
- checksums.yaml.gz.sig +2 -2
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +8 -12
- data/LICENSE +1 -1
- data/README.md +19 -40
- data/bin/autoscaling-instance-count-metrics.rb +0 -1
- data/bin/check-dynamodb-capacity.rb +1 -2
- data/bin/check-dynamodb-throttle.rb +0 -1
- data/bin/check-ec2-network.rb +0 -1
- data/bin/check-elb-certs.rb +2 -3
- data/bin/check-elb-health-fog.rb +0 -1
- data/bin/check-elb-health-sdk.rb +0 -1
- data/bin/check-elb-health.rb +0 -1
- data/bin/check-elb-latency.rb +1 -2
- data/bin/check-elb-nodes.rb +1 -2
- data/bin/check-elb-sum-requests.rb +0 -1
- data/bin/check-instance-events.rb +2 -4
- data/bin/check-rds.rb +12 -13
- data/bin/check-ses-limit.rb +1 -2
- data/bin/check-sqs-messages.rb +4 -1
- data/bin/{ec2-node.rb → handler-ec2-node.rb} +0 -1
- data/bin/handler-ec2_node.rb +156 -0
- data/bin/handler-sns.rb +74 -0
- data/bin/{ec2-count-metrics.rb → metrics-ec2-count.rb} +2 -3
- data/bin/{elasticache-metrics.rb → metrics-elasticache.rb} +0 -1
- data/bin/{elb-full-metrics.rb → metrics-elb-full.rb} +10 -8
- data/bin/{elb-metrics.rb → metrics-elb.rb} +4 -2
- data/bin/{sqs-metrics.rb → metrics-sqs.rb} +0 -1
- data/lib/sensu-plugins-aws.rb +15 -0
- data/lib/sensu-plugins-aws/version.rb +28 -0
- metadata +62 -80
- metadata.gz.sig +0 -0
- data/bin/elb-latency-metrics.rb +0 -150
- data/lib/sensu-plugins-AWS.rb +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 09a4ab59256df028e1b8f30fca0f35ca94695718
|
|
4
|
+
data.tar.gz: e28188693388835bde54d7d1b10436536f435694
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a9ede4cfc71b4247a145cdbc7a4fb8b3a01001857ce97cc323e75ae2be3a76ab9e3da21117a577b0e01e29149ef729b35767f8a7f11c2a733dd3f85072f17496
|
|
7
|
+
data.tar.gz: 599dbee54f3c1d6e3d936f72d3b0ac56e49d9ab8a2cb74da1ab43c04b9e37c29b5a09d168d0a406cd57686331222ab5c86d7dbc429300769cb40aa30783a9af4
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
�t,ʍ#XP�I]���Bɮ��D8��@��I�[t4�Zv��]�$"��j/62"FF�y�(����G|W~13�3��ߐ���k��,���:!��M�х�;�_"y�8�vF�*t ��Q�N���h����:��IX�Gq�����u�
|
|
2
|
+
t뗫R��$O�+�^\�,��K�3>�/�UѾ[�a#�A�̟GKj�T/�.�S�LC�]Ba�m��<�bPbo�"f�����'�׳L��!��ݮ��c$��Wb�������WQ� �
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
#Change Log
|
|
2
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
* removed check-vpc-vpn.py
|
|
5
|
-
* built against 1.9.3, 2.0, 2.1
|
|
6
|
-
* change the ec2_node.rb to ec2-node.rb
|
|
4
|
+
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
## Unreleased][unreleased]
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* added check-vpc-vpn.py (may be removed before first stable release)
|
|
15
|
-
* pulled latest script version from community repo
|
|
8
|
+
## 0.0.1 - 2015-05-21
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- initial release
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-aws)
|
|
6
6
|
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-aws)
|
|
7
7
|
[](https://gemnasium.com/sensu-plugins/sensu-plugins-aws)
|
|
8
|
+
[ ](https://codeship.com/projects/77866)
|
|
8
9
|
|
|
9
10
|
## Functionality
|
|
10
11
|
|
|
@@ -75,51 +76,29 @@
|
|
|
75
76
|
* /bin/check-redshift-events.rb
|
|
76
77
|
* /bin/check-ses-limit.rb
|
|
77
78
|
* /bin/check-sqs-messages.rb
|
|
78
|
-
* /bin/ec2-count
|
|
79
|
-
* /bin/ec2-node.rb
|
|
80
|
-
* /bin/elasticache
|
|
81
|
-
* /bin/elb-full
|
|
82
|
-
* /bin/elb-latency
|
|
83
|
-
* /bin/elb
|
|
84
|
-
* /bin/sqs
|
|
79
|
+
* /bin/metrics-ec2-count.rb
|
|
80
|
+
* /bin/handler-ec2-node.rb
|
|
81
|
+
* /bin/metrics-elasticache.rb
|
|
82
|
+
* /bin/metrics-elb-full.rb
|
|
83
|
+
* /bin/metrics-elb-latency.rb
|
|
84
|
+
* /bin/metrics-elb.rb
|
|
85
|
+
* /bin/metrics-sqs.rb
|
|
85
86
|
|
|
86
87
|
## Usage
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
Add the public key (if you haven’t already) as a trusted certificate
|
|
91
|
-
|
|
89
|
+
**handler-sns**
|
|
92
90
|
```
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
`gem install sensu-plugins-aws`
|
|
102
|
-
|
|
103
|
-
#### Bundler
|
|
104
|
-
|
|
105
|
-
Add *sensu-plugins-aws* to your Gemfile and run `bundle install` or `bundle update`
|
|
106
|
-
|
|
107
|
-
#### Chef
|
|
108
|
-
|
|
109
|
-
Using the Sensu **sensu_gem** LWRP
|
|
110
|
-
```
|
|
111
|
-
sensu_gem 'sensu-plugins-aws' do
|
|
112
|
-
options('--prerelease')
|
|
113
|
-
version '0.0.1.alpha.2'
|
|
114
|
-
end
|
|
91
|
+
{
|
|
92
|
+
"sns": {
|
|
93
|
+
"topic_arn": "arn:aws:sns:us-east-1:111111111111:topic"
|
|
94
|
+
,"use_ami_role": true
|
|
95
|
+
,"access_key": "MY_KEY"
|
|
96
|
+
,"secret_key": "MY_secret"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
115
99
|
```
|
|
100
|
+
## Installation
|
|
116
101
|
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
gem_package 'sensu-plugins-process-checks' do
|
|
120
|
-
options('--prerelease')
|
|
121
|
-
version '0.0.1.alpha.2'
|
|
122
|
-
end
|
|
123
|
-
```
|
|
102
|
+
[Installation and Setup](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
|
|
124
103
|
|
|
125
104
|
## Notes
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
# for details.
|
|
32
32
|
#
|
|
33
33
|
|
|
34
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
35
34
|
require 'sensu-plugin/check/cli'
|
|
36
35
|
require 'aws-sdk'
|
|
37
36
|
require 'time'
|
|
@@ -154,7 +153,7 @@ class CheckDynamoDB < Sensu::Plugin::Check::CLI
|
|
|
154
153
|
threshold = config[:"#{severity}_over"]
|
|
155
154
|
next unless threshold
|
|
156
155
|
next if percentage < threshold
|
|
157
|
-
flag_alert severity, "; On table #{table.name} consumed #{r_or_w} capacity is #{sprintf '%.2f', percentage}% (expected_lower_than #{threshold})"
|
|
156
|
+
flag_alert severity, "; On table #{table.name} consumed #{r_or_w} capacity is #{sprintf '%.2f', percentage}% (expected_lower_than #{threshold})" # rubocop:disable all
|
|
158
157
|
break
|
|
159
158
|
end
|
|
160
159
|
end
|
data/bin/check-ec2-network.rb
CHANGED
data/bin/check-elb-certs.rb
CHANGED
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
# for details.
|
|
32
32
|
#
|
|
33
33
|
|
|
34
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
35
34
|
require 'sensu-plugin/check/cli'
|
|
36
35
|
require 'aws-sdk'
|
|
37
36
|
require 'net/http'
|
|
@@ -90,7 +89,7 @@ class CheckELBCerts < Sensu::Plugin::Check::CLI
|
|
|
90
89
|
hash
|
|
91
90
|
end
|
|
92
91
|
|
|
93
|
-
def run
|
|
92
|
+
def run # rubocop:disable all
|
|
94
93
|
ok_message = []
|
|
95
94
|
warning_message = []
|
|
96
95
|
critical_message = []
|
|
@@ -116,7 +115,7 @@ class CheckELBCerts < Sensu::Plugin::Check::CLI
|
|
|
116
115
|
end
|
|
117
116
|
|
|
118
117
|
cert_days_remaining = ((cert.not_after - Time.now) / 86_400).to_i
|
|
119
|
-
message = sprintf '%s(%d)', lb.name, cert_days_remaining
|
|
118
|
+
message = sprintf '%s(%d)', lb.name, cert_days_remaining # rubocop:disable all
|
|
120
119
|
|
|
121
120
|
if config[:crit_under] > 0 && config[:crit_under] >= cert_days_remaining
|
|
122
121
|
critical_message << message
|
data/bin/check-elb-health-fog.rb
CHANGED
data/bin/check-elb-health-sdk.rb
CHANGED
data/bin/check-elb-health.rb
CHANGED
data/bin/check-elb-latency.rb
CHANGED
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
# for details.
|
|
32
32
|
#
|
|
33
33
|
|
|
34
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
35
34
|
require 'sensu-plugin/check/cli'
|
|
36
35
|
require 'aws-sdk'
|
|
37
36
|
|
|
@@ -142,7 +141,7 @@ class CheckELBLatency < Sensu::Plugin::Check::CLI
|
|
|
142
141
|
next unless threshold
|
|
143
142
|
next if metric_value < threshold
|
|
144
143
|
flag_alert severity,
|
|
145
|
-
"; #{elbs.size == 1 ? nil : "#{elb.inspect}'s"} Latency is #{sprintf '%.3f', metric_value} seconds. (expected lower than #{sprintf '%.3f', threshold})"
|
|
144
|
+
"; #{elbs.size == 1 ? nil : "#{elb.inspect}'s"} Latency is #{sprintf '%.3f', metric_value} seconds. (expected lower than #{sprintf '%.3f', threshold})" # rubocop:disable all
|
|
146
145
|
break
|
|
147
146
|
end
|
|
148
147
|
end
|
data/bin/check-elb-nodes.rb
CHANGED
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
# for details.
|
|
32
32
|
#
|
|
33
33
|
|
|
34
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
35
34
|
require 'sensu-plugin/check/cli'
|
|
36
35
|
require 'aws-sdk'
|
|
37
36
|
|
|
@@ -94,7 +93,7 @@ class CheckELBNodes < Sensu::Plugin::Check::CLI
|
|
|
94
93
|
hash
|
|
95
94
|
end
|
|
96
95
|
|
|
97
|
-
def run
|
|
96
|
+
def run # rubocop:disable all
|
|
98
97
|
AWS.start_memoizing
|
|
99
98
|
elb = AWS::ELB.new aws_config
|
|
100
99
|
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
# for details.
|
|
28
28
|
#
|
|
29
29
|
|
|
30
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
31
30
|
require 'sensu-plugin/check/cli'
|
|
32
31
|
require 'aws-sdk'
|
|
33
32
|
|
|
@@ -75,15 +74,14 @@ class CheckInstanceEvents < Sensu::Plugin::Check::CLI
|
|
|
75
74
|
|
|
76
75
|
if config[:use_iam_role].nil?
|
|
77
76
|
aws_config.merge!(
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
access_key_id: config[:aws_access_key],
|
|
78
|
+
secret_access_key: config[:aws_secret_access_key]
|
|
80
79
|
)
|
|
81
80
|
end
|
|
82
81
|
|
|
83
82
|
ec2 = AWS::EC2::Client.new(aws_config.merge!(region: config[:aws_region]))
|
|
84
83
|
begin
|
|
85
84
|
ec2.describe_instance_status[:instance_status_set].each do |i| # rubocop:disable Next
|
|
86
|
-
|
|
87
85
|
unless i[:events_set].empty?
|
|
88
86
|
# Exclude completed reboots since the events API appearently returns these even after they have been completed:
|
|
89
87
|
# Example:
|
data/bin/check-rds.rb
CHANGED
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
# for details.
|
|
44
44
|
#
|
|
45
45
|
|
|
46
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
47
46
|
require 'sensu-plugin/check/cli'
|
|
48
47
|
require 'aws-sdk'
|
|
49
48
|
require 'time'
|
|
@@ -189,30 +188,30 @@ class CheckRDS < Sensu::Plugin::Check::CLI
|
|
|
189
188
|
end
|
|
190
189
|
|
|
191
190
|
def check_cpu(severity, expected_lower_than)
|
|
192
|
-
@cpu_metric
|
|
191
|
+
@cpu_metric ||= cloud_watch_metric 'CPUUtilization'
|
|
193
192
|
@cpu_metric_value ||= latest_value @cpu_metric, 'Percent'
|
|
194
193
|
return if @cpu_metric_value < expected_lower_than
|
|
195
|
-
flag_alert severity, "; CPUUtilization is #{sprintf '%.2f', @cpu_metric_value}% (expected lower than #{expected_lower_than}%)"
|
|
194
|
+
flag_alert severity, "; CPUUtilization is #{sprintf '%.2f', @cpu_metric_value}% (expected lower than #{expected_lower_than}%)" # rubocop:disable all
|
|
196
195
|
end
|
|
197
196
|
|
|
198
197
|
def check_memory(severity, expected_lower_than)
|
|
199
|
-
@memory_metric
|
|
200
|
-
@memory_metric_value
|
|
201
|
-
@memory_total_bytes
|
|
202
|
-
@memory_usage_bytes
|
|
198
|
+
@memory_metric ||= cloud_watch_metric 'FreeableMemory'
|
|
199
|
+
@memory_metric_value ||= latest_value @memory_metric, 'Bytes'
|
|
200
|
+
@memory_total_bytes ||= memory_total_bytes @db_instance.db_instance_class
|
|
201
|
+
@memory_usage_bytes ||= @memory_total_bytes - @memory_metric_value
|
|
203
202
|
@memory_usage_percentage ||= @memory_usage_bytes / @memory_total_bytes * 100
|
|
204
203
|
return if @memory_usage_percentage < expected_lower_than
|
|
205
|
-
flag_alert severity, "; Memory usage is #{sprintf '%.2f', @memory_usage_percentage}% (expected lower than #{expected_lower_than}%)"
|
|
204
|
+
flag_alert severity, "; Memory usage is #{sprintf '%.2f', @memory_usage_percentage}% (expected lower than #{expected_lower_than}%)" # rubocop:disable all
|
|
206
205
|
end
|
|
207
206
|
|
|
208
207
|
def check_disk(severity, expected_lower_than)
|
|
209
|
-
@disk_metric
|
|
210
|
-
@disk_metric_value
|
|
211
|
-
@disk_total_bytes
|
|
212
|
-
@disk_usage_bytes
|
|
208
|
+
@disk_metric ||= cloud_watch_metric 'FreeStorageSpace'
|
|
209
|
+
@disk_metric_value ||= latest_value @disk_metric, 'Bytes'
|
|
210
|
+
@disk_total_bytes ||= @db_instance.allocated_storage * 1024**3
|
|
211
|
+
@disk_usage_bytes ||= @disk_total_bytes - @disk_metric_value
|
|
213
212
|
@disk_usage_percentage ||= @disk_usage_bytes / @disk_total_bytes * 100
|
|
214
213
|
return if @disk_usage_percentage < expected_lower_than
|
|
215
|
-
flag_alert severity, "; Disk usage is #{sprintf '%.2f', @disk_usage_percentage}% (expected lower than #{expected_lower_than}%)"
|
|
214
|
+
flag_alert severity, "; Disk usage is #{sprintf '%.2f', @disk_usage_percentage}% (expected lower than #{expected_lower_than}%)" # rubocop:disable all
|
|
216
215
|
end
|
|
217
216
|
|
|
218
217
|
def run
|
data/bin/check-ses-limit.rb
CHANGED
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
# for details.
|
|
29
29
|
#
|
|
30
30
|
|
|
31
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
32
31
|
require 'sensu-plugin/check/cli'
|
|
33
32
|
require 'aws/ses'
|
|
34
33
|
|
|
@@ -75,7 +74,7 @@ class CheckSESLimit < Sensu::Plugin::Check::CLI
|
|
|
75
74
|
critical "An issue occured while communicating with the AWS SES API: #{e.message}"
|
|
76
75
|
end
|
|
77
76
|
|
|
78
|
-
unless response.empty?
|
|
77
|
+
unless response.empty? # rubocop: disable Style/GuardClause
|
|
79
78
|
percent = (response.sent_last_24_hours.to_i / response.max_24_hour_send.to_i) * 100
|
|
80
79
|
message = "SES sending limit is at #{percent}%"
|
|
81
80
|
|
data/bin/check-sqs-messages.rb
CHANGED
|
@@ -27,10 +27,12 @@
|
|
|
27
27
|
# for details.
|
|
28
28
|
#
|
|
29
29
|
|
|
30
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
31
30
|
require 'sensu-plugin/check/cli'
|
|
32
31
|
require 'aws-sdk'
|
|
33
32
|
|
|
33
|
+
#
|
|
34
|
+
# Check SQS Messages
|
|
35
|
+
#
|
|
34
36
|
class SQSMsgs < Sensu::Plugin::Check::CLI
|
|
35
37
|
option :aws_access_key,
|
|
36
38
|
short: '-a AWS_ACCESS_KEY',
|
|
@@ -88,6 +90,7 @@ class SQSMsgs < Sensu::Plugin::Check::CLI
|
|
|
88
90
|
hash = {}
|
|
89
91
|
hash.update access_key_id: config[:aws_access_key], secret_access_key: config[:aws_secret_access_key]\
|
|
90
92
|
if config[:aws_access_key] && config[:aws_secret_access_key]
|
|
93
|
+
hash.update region: config[:aws_region]
|
|
91
94
|
hash
|
|
92
95
|
end
|
|
93
96
|
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# CHANGELOG:
|
|
4
|
+
# * 0.4.0:
|
|
5
|
+
# - Adds ability to specify a list of states an individual client can have in
|
|
6
|
+
# EC2. If none is specified, it filters out 'terminated' and 'stopped'
|
|
7
|
+
# instances by default.
|
|
8
|
+
# - Updates how we are "puts"-ing to the log.
|
|
9
|
+
# * 0.3.0:
|
|
10
|
+
# - Updates handler to additionally filter stopped instances.
|
|
11
|
+
# * 0.2.1:
|
|
12
|
+
# - Updates requested configuration snippets so they'll be redacted by
|
|
13
|
+
# default.
|
|
14
|
+
# * 0.2.0:
|
|
15
|
+
# - Renames handler from chef_ec2_node to ec2_node
|
|
16
|
+
# - Removes Chef-related stuff from handler
|
|
17
|
+
# - Updates documentation
|
|
18
|
+
# * 0.1.0:
|
|
19
|
+
# - Initial release
|
|
20
|
+
#
|
|
21
|
+
# This handler deletes a Sensu client if it's been stopped or terminated in EC2.
|
|
22
|
+
# Optionally, you may specify a client attribute `ec2_states`, a list of valid
|
|
23
|
+
# states an instance may have.
|
|
24
|
+
#
|
|
25
|
+
# NOTE: The implementation for correlating Sensu clients to EC2 instances may
|
|
26
|
+
# need to be modified to fit your organization. The current implementation
|
|
27
|
+
# assumes that Sensu clients' names are the same as their instance IDs in EC2.
|
|
28
|
+
# If this is not the case, you can either sub-class this handler and override
|
|
29
|
+
# `ec2_node_exists?` in your own organization-specific handler, or modify this
|
|
30
|
+
# handler to suit your needs.
|
|
31
|
+
#
|
|
32
|
+
# Requires the following Rubygems (`gem install $GEM`):
|
|
33
|
+
# - sensu-plugin
|
|
34
|
+
# - fog
|
|
35
|
+
#
|
|
36
|
+
# Requires a Sensu configuration snippet:
|
|
37
|
+
# {
|
|
38
|
+
# "aws": {
|
|
39
|
+
# "access_key": "adsafdafda",
|
|
40
|
+
# "secret_key": "qwuieohajladsafhj23nm",
|
|
41
|
+
# "region": "us-east-1c"
|
|
42
|
+
# }
|
|
43
|
+
# }
|
|
44
|
+
#
|
|
45
|
+
# Or you can set the following environment variables:
|
|
46
|
+
# - AWS_ACCESS_KEY_ID
|
|
47
|
+
# - AWS_SECRET_ACCESS_KEY
|
|
48
|
+
# - EC2_REGION
|
|
49
|
+
#
|
|
50
|
+
#
|
|
51
|
+
# To use, you can set it as the keepalive handler for a client:
|
|
52
|
+
# {
|
|
53
|
+
# "client": {
|
|
54
|
+
# "name": "i-424242",
|
|
55
|
+
# "address": "127.0.0.1",
|
|
56
|
+
# "keepalive": {
|
|
57
|
+
# "handler": "ec2_node"
|
|
58
|
+
# },
|
|
59
|
+
# "subscriptions": ["all"]
|
|
60
|
+
# }
|
|
61
|
+
# }
|
|
62
|
+
#
|
|
63
|
+
# You can also use this handler with a filter:
|
|
64
|
+
# {
|
|
65
|
+
# "filters": {
|
|
66
|
+
# "ghost_nodes": {
|
|
67
|
+
# "attributes": {
|
|
68
|
+
# "check": {
|
|
69
|
+
# "name": "keepalive",
|
|
70
|
+
# "status": 2
|
|
71
|
+
# },
|
|
72
|
+
# "occurences": "eval: value > 2"
|
|
73
|
+
# }
|
|
74
|
+
# }
|
|
75
|
+
# },
|
|
76
|
+
# "handlers": {
|
|
77
|
+
# "ec2_node": {
|
|
78
|
+
# "type": "pipe",
|
|
79
|
+
# "command": "/etc/sensu/handlers/ec2_node.rb",
|
|
80
|
+
# "severities": ["warning","critical"],
|
|
81
|
+
# "filter": "ghost_nodes"
|
|
82
|
+
# }
|
|
83
|
+
# }
|
|
84
|
+
# }
|
|
85
|
+
#
|
|
86
|
+
# Copyleft 2013 Yet Another Clever Name
|
|
87
|
+
#
|
|
88
|
+
# Based off of the `chef_node` handler by Heavy Water Operations, LLC
|
|
89
|
+
#
|
|
90
|
+
# Released under the same terms as Sensu (the MIT license); see
|
|
91
|
+
# LICENSE for details
|
|
92
|
+
|
|
93
|
+
require 'timeout'
|
|
94
|
+
require 'sensu-handler'
|
|
95
|
+
require 'fog'
|
|
96
|
+
|
|
97
|
+
class Ec2Node < Sensu::Handler
|
|
98
|
+
def filter; end
|
|
99
|
+
|
|
100
|
+
def handle
|
|
101
|
+
# #YELLOW
|
|
102
|
+
unless ec2_node_exists? # rubocop:disable UnlessElse
|
|
103
|
+
delete_sensu_client!
|
|
104
|
+
else
|
|
105
|
+
puts "[EC2 Node] #{@event['client']['name']} appears to exist in EC2"
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def delete_sensu_client!
|
|
110
|
+
response = api_request(:DELETE, '/clients/' + @event['client']['name']).code
|
|
111
|
+
deletion_status(response)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def ec2_node_exists?
|
|
115
|
+
states = acquire_valid_states
|
|
116
|
+
filtered_instances = ec2.servers.select { |s| states.include?(s.state) }
|
|
117
|
+
instance_ids = filtered_instances.map(&:id)
|
|
118
|
+
instance_ids.each do |id|
|
|
119
|
+
return true if id == @event['client']['name']
|
|
120
|
+
end
|
|
121
|
+
false # no match found, node doesn't exist
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def ec2
|
|
125
|
+
@ec2 ||= begin
|
|
126
|
+
key = settings['aws']['access_key'] || ENV['AWS_ACCESS_KEY_ID']
|
|
127
|
+
secret = settings['aws']['secret_key'] || ENV['AWS_SECRET_ACCESS_KEY']
|
|
128
|
+
region = settings['aws']['region'] || ENV['EC2_REGION']
|
|
129
|
+
Fog::Compute.new(provider: 'AWS',
|
|
130
|
+
aws_access_key_id: key,
|
|
131
|
+
aws_secret_access_key: secret,
|
|
132
|
+
region: region)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def deletion_status(code)
|
|
137
|
+
case code
|
|
138
|
+
when '202'
|
|
139
|
+
puts "[EC2 Node] 202: Successfully deleted Sensu client: #{node}"
|
|
140
|
+
when '404'
|
|
141
|
+
puts "[EC2 Node] 404: Unable to delete #{node}, doesn't exist!"
|
|
142
|
+
when '500'
|
|
143
|
+
puts "[EC2 Node] 500: Miscellaneous error when deleting #{node}"
|
|
144
|
+
else
|
|
145
|
+
puts "[EC2 Node] #{res}: Completely unsure of what happened!"
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def acquire_valid_states
|
|
150
|
+
if @event['client'].key?('ec2_states')
|
|
151
|
+
return @event['client']['ec2_states']
|
|
152
|
+
else
|
|
153
|
+
return ['running']
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
data/bin/handler-sns.rb
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This handler assumes it runs on an ec2 instance with an iam role
|
|
4
|
+
# that has permission to send to the sns topic specified in the config.
|
|
5
|
+
# This removes the requirement to specify an access key and secret access key.
|
|
6
|
+
# See http://docs.aws.amazon.com/IAM/latest/UserGuide/WorkingWithRoles.html
|
|
7
|
+
#
|
|
8
|
+
# Requires the aws-sdk gem.
|
|
9
|
+
#
|
|
10
|
+
# Setting required in sns.json
|
|
11
|
+
# topic_are : The arn for the destination sns topic
|
|
12
|
+
#
|
|
13
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
|
14
|
+
# for details
|
|
15
|
+
|
|
16
|
+
require 'sensu-handler'
|
|
17
|
+
require 'aws-sdk'
|
|
18
|
+
|
|
19
|
+
class SnsNotifier < Sensu::Handler
|
|
20
|
+
def topic_arn
|
|
21
|
+
settings['sns']['topic_arn']
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def region
|
|
25
|
+
settings['sns']['region'] || 'us-east-1'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def event_name
|
|
29
|
+
"#{@event['client']['name']}/#{@event['check']['name']}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def use_ami_role
|
|
33
|
+
use_ami_role = settings['sns']['use_ami_role']
|
|
34
|
+
use_ami_role.nil? ? true : use_ami_role
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def aws_access_key
|
|
38
|
+
settings['sns']['access_key'] || ''
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def aws_access_secret
|
|
42
|
+
settings['sns']['secret_key'] || ''
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def message
|
|
46
|
+
@event['check']['notification'] || @event['check']['output']
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def handle
|
|
50
|
+
if use_ami_role
|
|
51
|
+
AWS.config(region: region)
|
|
52
|
+
else
|
|
53
|
+
AWS.config(access_key_id: aws_access_key,
|
|
54
|
+
secret_access_key: aws_access_secret,
|
|
55
|
+
region: region)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
sns = AWS::SNS.new
|
|
59
|
+
|
|
60
|
+
t = sns.topics[topic_arn]
|
|
61
|
+
|
|
62
|
+
if @event['action'].eql?('resolve')
|
|
63
|
+
subject = "RESOLVED - [#{event_name}]"
|
|
64
|
+
options = { subject: subject }
|
|
65
|
+
t.publish("#{subject} - #{message}", options)
|
|
66
|
+
else
|
|
67
|
+
subject = "ALERT - [#{event_name}]"
|
|
68
|
+
options = { subject: subject }
|
|
69
|
+
t.publish("#{subject} - #{message}", options)
|
|
70
|
+
end
|
|
71
|
+
rescue => e
|
|
72
|
+
puts "Exception occured in SnsNotifier: #{e.message}", e.backtrace
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
# for details.
|
|
27
27
|
#
|
|
28
28
|
|
|
29
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
30
29
|
require 'sensu-plugin/metric/cli'
|
|
31
30
|
require 'aws-sdk'
|
|
32
31
|
|
|
@@ -93,7 +92,7 @@ class EC2Metrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
93
92
|
end
|
|
94
93
|
end
|
|
95
94
|
|
|
96
|
-
unless data.nil?
|
|
95
|
+
unless data.nil? # rubocop: disable Style/GuardClause
|
|
97
96
|
# We only return data when we have some to return
|
|
98
97
|
output config[:scheme] + '.total', total
|
|
99
98
|
status.each do |name, count|
|
|
@@ -121,7 +120,7 @@ class EC2Metrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
121
120
|
end
|
|
122
121
|
end
|
|
123
122
|
|
|
124
|
-
unless data.nil?
|
|
123
|
+
unless data.nil? # rubocop: disable Style/GuardClause
|
|
125
124
|
# We only return data when we have some to return
|
|
126
125
|
data.each do |name, count|
|
|
127
126
|
output config[:scheme] + ".#{name}", count
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
# for details.
|
|
33
33
|
#
|
|
34
34
|
|
|
35
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
36
35
|
require 'sensu-plugin/metric/cli'
|
|
37
36
|
require 'aws-sdk'
|
|
38
37
|
|
|
@@ -92,7 +91,10 @@ class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
92
91
|
'HTTPCode_Backend_4XX' => 'Sum',
|
|
93
92
|
'HTTPCode_Backend_5XX' => 'Sum',
|
|
94
93
|
'HTTPCode_ELB_4XX' => 'Sum',
|
|
95
|
-
'HTTPCode_ELB_5XX' => 'Sum'
|
|
94
|
+
'HTTPCode_ELB_5XX' => 'Sum',
|
|
95
|
+
'BackendConnectionErrors' => 'Sum',
|
|
96
|
+
'SurgeQueueLength' => 'Max',
|
|
97
|
+
'SpilloverCount' => 'Sum'
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
begin
|
|
@@ -128,12 +130,12 @@ class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
128
130
|
r = cw.get_metric_statistics(options)
|
|
129
131
|
result[key] = r[:datapoints][0] unless r[:datapoints][0].nil?
|
|
130
132
|
end
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
|
|
134
|
+
# We only return data when we have some to return
|
|
135
|
+
next if result.nil?
|
|
136
|
+
result.each do |key, value|
|
|
137
|
+
puts key, value
|
|
138
|
+
output graphitepath + ".#{key}", value.to_a.last[1], value[:timestamp].to_i
|
|
137
139
|
end
|
|
138
140
|
end
|
|
139
141
|
rescue => e
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
#
|
|
34
34
|
#
|
|
35
35
|
|
|
36
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
37
36
|
require 'sensu-plugin/metric/cli'
|
|
38
37
|
require 'aws-sdk'
|
|
39
38
|
|
|
@@ -105,7 +104,10 @@ class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
105
104
|
'HTTPCode_Backend_4XX' => 'Sum',
|
|
106
105
|
'HTTPCode_Backend_5XX' => 'Sum',
|
|
107
106
|
'HTTPCode_ELB_4XX' => 'Sum',
|
|
108
|
-
'HTTPCode_ELB_5XX' => 'Sum'
|
|
107
|
+
'HTTPCode_ELB_5XX' => 'Sum',
|
|
108
|
+
'BackendConnectionErrors' => 'Sum',
|
|
109
|
+
'SurgeQueueLength' => 'Max',
|
|
110
|
+
'SpilloverCount' => 'Sum'
|
|
109
111
|
}
|
|
110
112
|
statistic = default_statistic_per_metric[config[:metric]]
|
|
111
113
|
else
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
# encoding: utf-8
|
|
4
|
+
module SensuPluginsAWS
|
|
5
|
+
# This defines the version of the gem
|
|
6
|
+
module Version
|
|
7
|
+
MAJOR = 0
|
|
8
|
+
MINOR = 0
|
|
9
|
+
PATCH = 1
|
|
10
|
+
|
|
11
|
+
VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
|
|
12
|
+
|
|
13
|
+
NAME = 'sensu-plugins-aws'
|
|
14
|
+
BANNER = "#{NAME} v%s"
|
|
15
|
+
|
|
16
|
+
module_function
|
|
17
|
+
|
|
18
|
+
def version
|
|
19
|
+
format(BANNER, VER_STRING)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def json_version
|
|
23
|
+
{
|
|
24
|
+
'version' => VER_STRING
|
|
25
|
+
}.to_json
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
metadata
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sensu-plugins-aws
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.1
|
|
4
|
+
version: 0.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- Sensu Plugins and contributors
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain:
|
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
|
30
30
|
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
|
31
31
|
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
|
32
32
|
-----END CERTIFICATE-----
|
|
33
|
-
date: 2015-
|
|
33
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
|
34
34
|
dependencies:
|
|
35
35
|
- !ruby/object:Gem::Dependency
|
|
36
36
|
name: sensu-plugin
|
|
@@ -120,159 +120,137 @@ dependencies:
|
|
|
120
120
|
name: codeclimate-test-reporter
|
|
121
121
|
requirement: !ruby/object:Gem::Requirement
|
|
122
122
|
requirements:
|
|
123
|
-
- -
|
|
123
|
+
- - "~>"
|
|
124
124
|
- !ruby/object:Gem::Version
|
|
125
|
-
version: '0'
|
|
125
|
+
version: '0.4'
|
|
126
126
|
type: :development
|
|
127
127
|
prerelease: false
|
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
|
129
129
|
requirements:
|
|
130
|
-
- -
|
|
130
|
+
- - "~>"
|
|
131
131
|
- !ruby/object:Gem::Version
|
|
132
|
-
version: '0'
|
|
132
|
+
version: '0.4'
|
|
133
133
|
- !ruby/object:Gem::Dependency
|
|
134
134
|
name: rubocop
|
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
|
136
136
|
requirements:
|
|
137
|
-
- - ~>
|
|
137
|
+
- - "~>"
|
|
138
138
|
- !ruby/object:Gem::Version
|
|
139
|
-
version: 0.
|
|
139
|
+
version: '0.30'
|
|
140
140
|
type: :development
|
|
141
141
|
prerelease: false
|
|
142
142
|
version_requirements: !ruby/object:Gem::Requirement
|
|
143
143
|
requirements:
|
|
144
|
-
- - ~>
|
|
144
|
+
- - "~>"
|
|
145
145
|
- !ruby/object:Gem::Version
|
|
146
|
-
version: 0.
|
|
146
|
+
version: '0.30'
|
|
147
147
|
- !ruby/object:Gem::Dependency
|
|
148
148
|
name: rspec
|
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
|
150
150
|
requirements:
|
|
151
|
-
- - ~>
|
|
151
|
+
- - "~>"
|
|
152
152
|
- !ruby/object:Gem::Version
|
|
153
153
|
version: '3.1'
|
|
154
154
|
type: :development
|
|
155
155
|
prerelease: false
|
|
156
156
|
version_requirements: !ruby/object:Gem::Requirement
|
|
157
157
|
requirements:
|
|
158
|
-
- - ~>
|
|
158
|
+
- - "~>"
|
|
159
159
|
- !ruby/object:Gem::Version
|
|
160
160
|
version: '3.1'
|
|
161
161
|
- !ruby/object:Gem::Dependency
|
|
162
162
|
name: bundler
|
|
163
163
|
requirement: !ruby/object:Gem::Requirement
|
|
164
164
|
requirements:
|
|
165
|
-
- - ~>
|
|
165
|
+
- - "~>"
|
|
166
166
|
- !ruby/object:Gem::Version
|
|
167
167
|
version: '1.7'
|
|
168
168
|
type: :development
|
|
169
169
|
prerelease: false
|
|
170
170
|
version_requirements: !ruby/object:Gem::Requirement
|
|
171
171
|
requirements:
|
|
172
|
-
- - ~>
|
|
172
|
+
- - "~>"
|
|
173
173
|
- !ruby/object:Gem::Version
|
|
174
174
|
version: '1.7'
|
|
175
175
|
- !ruby/object:Gem::Dependency
|
|
176
176
|
name: rake
|
|
177
177
|
requirement: !ruby/object:Gem::Requirement
|
|
178
178
|
requirements:
|
|
179
|
-
- - ~>
|
|
179
|
+
- - "~>"
|
|
180
180
|
- !ruby/object:Gem::Version
|
|
181
181
|
version: '10.0'
|
|
182
182
|
type: :development
|
|
183
183
|
prerelease: false
|
|
184
184
|
version_requirements: !ruby/object:Gem::Requirement
|
|
185
185
|
requirements:
|
|
186
|
-
- - ~>
|
|
186
|
+
- - "~>"
|
|
187
187
|
- !ruby/object:Gem::Version
|
|
188
188
|
version: '10.0'
|
|
189
189
|
- !ruby/object:Gem::Dependency
|
|
190
190
|
name: github-markup
|
|
191
191
|
requirement: !ruby/object:Gem::Requirement
|
|
192
192
|
requirements:
|
|
193
|
-
- -
|
|
193
|
+
- - "~>"
|
|
194
194
|
- !ruby/object:Gem::Version
|
|
195
|
-
version: '
|
|
195
|
+
version: '1.3'
|
|
196
196
|
type: :development
|
|
197
197
|
prerelease: false
|
|
198
198
|
version_requirements: !ruby/object:Gem::Requirement
|
|
199
199
|
requirements:
|
|
200
|
-
- -
|
|
200
|
+
- - "~>"
|
|
201
201
|
- !ruby/object:Gem::Version
|
|
202
|
-
version: '
|
|
202
|
+
version: '1.3'
|
|
203
203
|
- !ruby/object:Gem::Dependency
|
|
204
204
|
name: redcarpet
|
|
205
205
|
requirement: !ruby/object:Gem::Requirement
|
|
206
206
|
requirements:
|
|
207
|
-
- -
|
|
207
|
+
- - "~>"
|
|
208
208
|
- !ruby/object:Gem::Version
|
|
209
|
-
version: '
|
|
209
|
+
version: '3.2'
|
|
210
210
|
type: :development
|
|
211
211
|
prerelease: false
|
|
212
212
|
version_requirements: !ruby/object:Gem::Requirement
|
|
213
213
|
requirements:
|
|
214
|
-
- -
|
|
214
|
+
- - "~>"
|
|
215
215
|
- !ruby/object:Gem::Version
|
|
216
|
-
version: '
|
|
216
|
+
version: '3.2'
|
|
217
217
|
- !ruby/object:Gem::Dependency
|
|
218
218
|
name: yard
|
|
219
219
|
requirement: !ruby/object:Gem::Requirement
|
|
220
220
|
requirements:
|
|
221
|
-
- -
|
|
221
|
+
- - "~>"
|
|
222
222
|
- !ruby/object:Gem::Version
|
|
223
|
-
version: '0'
|
|
223
|
+
version: '0.8'
|
|
224
224
|
type: :development
|
|
225
225
|
prerelease: false
|
|
226
226
|
version_requirements: !ruby/object:Gem::Requirement
|
|
227
227
|
requirements:
|
|
228
|
-
- -
|
|
228
|
+
- - "~>"
|
|
229
229
|
- !ruby/object:Gem::Version
|
|
230
|
-
version: '0'
|
|
230
|
+
version: '0.8'
|
|
231
231
|
- !ruby/object:Gem::Dependency
|
|
232
232
|
name: pry
|
|
233
233
|
requirement: !ruby/object:Gem::Requirement
|
|
234
234
|
requirements:
|
|
235
|
-
- -
|
|
235
|
+
- - "~>"
|
|
236
236
|
- !ruby/object:Gem::Version
|
|
237
|
-
version: '0'
|
|
237
|
+
version: '0.10'
|
|
238
238
|
type: :development
|
|
239
239
|
prerelease: false
|
|
240
240
|
version_requirements: !ruby/object:Gem::Requirement
|
|
241
241
|
requirements:
|
|
242
|
-
- -
|
|
242
|
+
- - "~>"
|
|
243
243
|
- !ruby/object:Gem::Version
|
|
244
|
-
version: '0'
|
|
245
|
-
description: Sensu
|
|
246
|
-
email: <sensu-users@googlegroups.com>
|
|
247
|
-
executables:
|
|
248
|
-
- autoscaling-instance-count-metrics.rb
|
|
249
|
-
- check-dynamodb-capacity.rb
|
|
250
|
-
- check-dynamodb-throttle.rb
|
|
251
|
-
- check-ec2-network.rb
|
|
252
|
-
- check-elb-certs.rb
|
|
253
|
-
- check-elb-health-fog.rb
|
|
254
|
-
- check-elb-health-sdk.rb
|
|
255
|
-
- check-elb-health.rb
|
|
256
|
-
- check-elb-latency.rb
|
|
257
|
-
- check-elb-nodes.rb
|
|
258
|
-
- check-elb-sum-requests.rb
|
|
259
|
-
- check-instance-events.rb
|
|
260
|
-
- check-rds-events.rb
|
|
261
|
-
- check-rds.rb
|
|
262
|
-
- check-redshift-events.rb
|
|
263
|
-
- check-ses-limit.rb
|
|
264
|
-
- check-sqs-messages.rb
|
|
265
|
-
- check_vpc_vpn.py
|
|
266
|
-
- ec2-count-metrics.rb
|
|
267
|
-
- ec2-node.rb
|
|
268
|
-
- elasticache-metrics.rb
|
|
269
|
-
- elb-full-metrics.rb
|
|
270
|
-
- elb-latency-metrics.rb
|
|
271
|
-
- elb-metrics.rb
|
|
272
|
-
- sqs-metrics.rb
|
|
244
|
+
version: '0.10'
|
|
245
|
+
description: Sensu plugins for working with an AWS environment
|
|
246
|
+
email: "<sensu-users@googlegroups.com>"
|
|
247
|
+
executables: []
|
|
273
248
|
extensions: []
|
|
274
249
|
extra_rdoc_files: []
|
|
275
250
|
files:
|
|
251
|
+
- CHANGELOG.md
|
|
252
|
+
- LICENSE
|
|
253
|
+
- README.md
|
|
276
254
|
- bin/autoscaling-instance-count-metrics.rb
|
|
277
255
|
- bin/check-dynamodb-capacity.rb
|
|
278
256
|
- bin/check-dynamodb-throttle.rb
|
|
@@ -291,40 +269,44 @@ files:
|
|
|
291
269
|
- bin/check-ses-limit.rb
|
|
292
270
|
- bin/check-sqs-messages.rb
|
|
293
271
|
- bin/check_vpc_vpn.py
|
|
294
|
-
- bin/ec2-
|
|
295
|
-
- bin/
|
|
296
|
-
- bin/
|
|
297
|
-
- bin/
|
|
298
|
-
- bin/
|
|
299
|
-
- bin/elb-
|
|
300
|
-
- bin/
|
|
301
|
-
-
|
|
302
|
-
-
|
|
303
|
-
-
|
|
304
|
-
- CHANGELOG.md
|
|
272
|
+
- bin/handler-ec2-node.rb
|
|
273
|
+
- bin/handler-ec2_node.rb
|
|
274
|
+
- bin/handler-sns.rb
|
|
275
|
+
- bin/metrics-ec2-count.rb
|
|
276
|
+
- bin/metrics-elasticache.rb
|
|
277
|
+
- bin/metrics-elb-full.rb
|
|
278
|
+
- bin/metrics-elb.rb
|
|
279
|
+
- bin/metrics-sqs.rb
|
|
280
|
+
- lib/sensu-plugins-aws.rb
|
|
281
|
+
- lib/sensu-plugins-aws/version.rb
|
|
305
282
|
homepage: https://github.com/sensu-plugins/sensu-plugins-aws
|
|
306
283
|
licenses:
|
|
307
284
|
- MIT
|
|
308
|
-
metadata:
|
|
309
|
-
|
|
285
|
+
metadata:
|
|
286
|
+
maintainer: ''
|
|
287
|
+
development_status: active
|
|
288
|
+
production_status: unstable - testing recommended
|
|
289
|
+
release_draft: 'false'
|
|
290
|
+
release_prerelease: 'false'
|
|
291
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
|
292
|
+
in /etc/default/sensu
|
|
310
293
|
rdoc_options: []
|
|
311
294
|
require_paths:
|
|
312
295
|
- lib
|
|
313
296
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
314
297
|
requirements:
|
|
315
|
-
- -
|
|
298
|
+
- - ">="
|
|
316
299
|
- !ruby/object:Gem::Version
|
|
317
300
|
version: 1.9.3
|
|
318
301
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
319
302
|
requirements:
|
|
320
|
-
- -
|
|
303
|
+
- - ">="
|
|
321
304
|
- !ruby/object:Gem::Version
|
|
322
|
-
version:
|
|
305
|
+
version: '0'
|
|
323
306
|
requirements: []
|
|
324
307
|
rubyforge_project:
|
|
325
|
-
rubygems_version: 2.
|
|
308
|
+
rubygems_version: 2.4.6
|
|
326
309
|
signing_key:
|
|
327
310
|
specification_version: 4
|
|
328
|
-
summary: Sensu
|
|
311
|
+
summary: Sensu plugins for working with an AWS environment
|
|
329
312
|
test_files: []
|
|
330
|
-
has_rdoc:
|
metadata.gz.sig
CHANGED
|
Binary file
|
data/bin/elb-latency-metrics.rb
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env ruby
|
|
2
|
-
#
|
|
3
|
-
# elb-latency-metrics
|
|
4
|
-
#
|
|
5
|
-
# DESCRIPTION:
|
|
6
|
-
# Gets latency metrics from CloudWatch and puts them in Graphite for longer term storage
|
|
7
|
-
#
|
|
8
|
-
# OUTPUT:
|
|
9
|
-
# metric-data
|
|
10
|
-
#
|
|
11
|
-
# PLATFORMS:
|
|
12
|
-
# Linux
|
|
13
|
-
#
|
|
14
|
-
# DEPENDENCIES:
|
|
15
|
-
# gem: sensu-plugin
|
|
16
|
-
#
|
|
17
|
-
# USAGE:
|
|
18
|
-
# #YELLOW
|
|
19
|
-
#
|
|
20
|
-
# NOTES:
|
|
21
|
-
# Returns latency statistics by default. You can specify any valid ELB metric type, see
|
|
22
|
-
# http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html#elb-metricscollected
|
|
23
|
-
#
|
|
24
|
-
# By default fetches statistics from one minute ago. You may need to fetch further back than this;
|
|
25
|
-
# high traffic ELBs can sometimes experience statistic delays of up to 10 minutes. If you experience this,
|
|
26
|
-
# raising a ticket with AWS support should get the problem resolved.
|
|
27
|
-
# As a workaround you can use eg -f 300 to fetch data from 5 minutes ago.
|
|
28
|
-
#
|
|
29
|
-
# LICENSE:
|
|
30
|
-
# Copyright 2013 Bashton Ltd http://www.bashton.com/
|
|
31
|
-
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
|
32
|
-
# for details.
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
|
|
36
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
37
|
-
require 'sensu-plugin/metric/cli'
|
|
38
|
-
require 'aws-sdk'
|
|
39
|
-
|
|
40
|
-
class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
41
|
-
option :elbname,
|
|
42
|
-
description: 'Name of the Elastic Load Balancer',
|
|
43
|
-
short: '-n ELB_NAME',
|
|
44
|
-
long: '--name ELB_NAME'
|
|
45
|
-
|
|
46
|
-
option :scheme,
|
|
47
|
-
description: 'Metric naming scheme, text to prepend to metric',
|
|
48
|
-
short: '-s SCHEME',
|
|
49
|
-
long: '--scheme SCHEME',
|
|
50
|
-
default: ''
|
|
51
|
-
|
|
52
|
-
option :fetch_age,
|
|
53
|
-
description: 'How long ago to fetch metrics for',
|
|
54
|
-
short: '-f AGE',
|
|
55
|
-
long: '--fetch_age',
|
|
56
|
-
default: 60,
|
|
57
|
-
proc: proc(&:to_i)
|
|
58
|
-
|
|
59
|
-
option :metric,
|
|
60
|
-
description: 'Metric to fetch',
|
|
61
|
-
short: '-m METRIC',
|
|
62
|
-
long: '--metric',
|
|
63
|
-
default: 'Latency'
|
|
64
|
-
|
|
65
|
-
option :statistic,
|
|
66
|
-
rescription: 'Statistics type',
|
|
67
|
-
short: '-t STATISTIC',
|
|
68
|
-
long: '--statistic',
|
|
69
|
-
default: ''
|
|
70
|
-
|
|
71
|
-
option :aws_access_key,
|
|
72
|
-
short: '-a AWS_ACCESS_KEY',
|
|
73
|
-
long: '--aws-access-key AWS_ACCESS_KEY',
|
|
74
|
-
description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
|
|
75
|
-
default: ENV['AWS_ACCESS_KEY']
|
|
76
|
-
|
|
77
|
-
option :aws_secret_access_key,
|
|
78
|
-
short: '-k AWS_SECRET_KEY',
|
|
79
|
-
long: '--aws-secret-access-key AWS_SECRET_KEY',
|
|
80
|
-
description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
|
|
81
|
-
default: ENV['AWS_SECRET_KEY']
|
|
82
|
-
|
|
83
|
-
option :aws_region,
|
|
84
|
-
short: '-r AWS_REGION',
|
|
85
|
-
long: '--aws-region REGION',
|
|
86
|
-
description: 'AWS Region (such as eu-west-1).',
|
|
87
|
-
default: 'us-east-1'
|
|
88
|
-
|
|
89
|
-
def aws_config
|
|
90
|
-
hash = {}
|
|
91
|
-
hash.update access_key_id: config[:access_key_id], secret_access_key: config[:secret_access_key] if config[:access_key_id] && config[:secret_access_key]
|
|
92
|
-
hash.update region: config[:aws_region]
|
|
93
|
-
hash
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def run
|
|
97
|
-
statistic = ''
|
|
98
|
-
if config[:statistic] == ''
|
|
99
|
-
default_statistic_per_metric = {
|
|
100
|
-
'Latency' => 'Average',
|
|
101
|
-
'RequestCount' => 'Sum',
|
|
102
|
-
'UnHealthyHostCount' => 'Average',
|
|
103
|
-
'HealthyHostCount' => 'Average',
|
|
104
|
-
'HTTPCode_Backend_2XX' => 'Sum',
|
|
105
|
-
'HTTPCode_Backend_4XX' => 'Sum',
|
|
106
|
-
'HTTPCode_Backend_5XX' => 'Sum',
|
|
107
|
-
'HTTPCode_ELB_4XX' => 'Sum',
|
|
108
|
-
'HTTPCode_ELB_5XX' => 'Sum'
|
|
109
|
-
}
|
|
110
|
-
statistic = default_statistic_per_metric[config[:metric]]
|
|
111
|
-
else
|
|
112
|
-
statistic = config[:statistic]
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
begin
|
|
116
|
-
et = Time.now - config[:fetch_age]
|
|
117
|
-
st = et - 60
|
|
118
|
-
|
|
119
|
-
cw = AWS::CloudWatch::Client.new aws_config
|
|
120
|
-
|
|
121
|
-
options = {
|
|
122
|
-
'namespace' => 'AWS/ELB',
|
|
123
|
-
'metric_name' => config[:metric],
|
|
124
|
-
'dimensions' => [
|
|
125
|
-
{
|
|
126
|
-
'name' => 'LoadBalancerName',
|
|
127
|
-
'value' => config[:elbname]
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
'statistics' => [statistic],
|
|
131
|
-
'start_time' => st.iso8601,
|
|
132
|
-
'end_time' => et.iso8601,
|
|
133
|
-
'period' => 60
|
|
134
|
-
}
|
|
135
|
-
result = cw.get_metric_statistics(options)
|
|
136
|
-
data = result[:datapoints][0]
|
|
137
|
-
unless data.nil?
|
|
138
|
-
# We only return data when we have some to return
|
|
139
|
-
graphitepath = config[:scheme]
|
|
140
|
-
if config[:scheme] == ''
|
|
141
|
-
graphitepath = "#{config[:elbname]}.#{config[:metric].downcase}"
|
|
142
|
-
end
|
|
143
|
-
output graphitepath, data[statistic.downcase.to_sym], data[:timestamp].to_i
|
|
144
|
-
end
|
|
145
|
-
rescue => e
|
|
146
|
-
critical "Error: exception: #{e}"
|
|
147
|
-
end
|
|
148
|
-
ok
|
|
149
|
-
end
|
|
150
|
-
end
|