sensu-plugins-aws 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,9 +4,9 @@ require 'json'
4
4
  module SensuPluginsAWS
5
5
  # This defines the version of the gem
6
6
  module Version
7
- MAJOR = 0
7
+ MAJOR = 1
8
8
  MINOR = 0
9
- PATCH = 4
9
+ PATCH = 0
10
10
 
11
11
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
@@ -30,7 +30,7 @@ cert_chain:
30
30
  8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
31
  HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
32
  -----END CERTIFICATE-----
33
- date: 2015-07-07 00:00:00.000000000 Z
33
+ date: 2015-07-22 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: sensu-plugin
@@ -38,28 +38,28 @@ dependencies:
38
38
  requirements:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: 1.1.0
41
+ version: 1.2.0
42
42
  type: :runtime
43
43
  prerelease: false
44
44
  version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: 1.1.0
48
+ version: 1.2.0
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: aws-sdk
51
51
  requirement: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 2.0.48
55
+ version: 2.1.7
56
56
  type: :runtime
57
57
  prerelease: false
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 2.0.48
62
+ version: 2.1.7
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: aws-sdk-v1
65
65
  requirement: !ruby/object:Gem::Requirement
@@ -80,14 +80,14 @@ dependencies:
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: 1.27.0
83
+ version: 1.32.0
84
84
  type: :runtime
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 1.27.0
90
+ version: 1.32.0
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: right_aws
93
93
  requirement: !ruby/object:Gem::Requirement
@@ -122,14 +122,14 @@ dependencies:
122
122
  requirements:
123
123
  - - '='
124
124
  - !ruby/object:Gem::Version
125
- version: '0.30'
125
+ version: 0.32.1
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.30'
132
+ version: 0.32.1
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: rspec
135
135
  requirement: !ruby/object:Gem::Requirement
@@ -236,9 +236,9 @@ executables:
236
236
  - metrics-elb-full.rb
237
237
  - metrics-elasticache.rb
238
238
  - metrics-ec2-count.rb
239
+ - metrics-autoscaling-instance-count.rb
239
240
  - handler-sns.rb
240
241
  - handler-ec2_node.rb
241
- - handler-ec2-node.rb
242
242
  - check_vpc_vpn.py
243
243
  - check-sqs-messages.rb
244
244
  - check-ses-limit.rb
@@ -257,14 +257,14 @@ executables:
257
257
  - check-ebs-snapshots.rb
258
258
  - check-dynamodb-throttle.rb
259
259
  - check-dynamodb-capacity.rb
260
- - autoscaling-instance-count-metrics.rb
260
+ - check-autoscaling-cpucredits.rb
261
261
  extensions: []
262
262
  extra_rdoc_files: []
263
263
  files:
264
264
  - CHANGELOG.md
265
265
  - LICENSE
266
266
  - README.md
267
- - bin/autoscaling-instance-count-metrics.rb
267
+ - bin/check-autoscaling-cpucredits.rb
268
268
  - bin/check-dynamodb-capacity.rb
269
269
  - bin/check-dynamodb-throttle.rb
270
270
  - bin/check-ebs-snapshots.rb
@@ -283,9 +283,9 @@ files:
283
283
  - bin/check-ses-limit.rb
284
284
  - bin/check-sqs-messages.rb
285
285
  - bin/check_vpc_vpn.py
286
- - bin/handler-ec2-node.rb
287
286
  - bin/handler-ec2_node.rb
288
287
  - bin/handler-sns.rb
288
+ - bin/metrics-autoscaling-instance-count.rb
289
289
  - bin/metrics-ec2-count.rb
290
290
  - bin/metrics-elasticache.rb
291
291
  - bin/metrics-elb-full.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,156 +0,0 @@
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