sensu-plugins-aws 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Njk5MmJjMzA1ZDFhYTJjZmM5YjZiZDcxOWFkODdhMzY4MDc5YTc5Nw==
4
+ NWI2YzJmMzQ4ZWVkZTI4YjI0N2EzMTA5YWMwZjU4ODcxNTFkMTAyMA==
5
5
  data.tar.gz: !binary |-
6
- Y2JhMGFkNTg5YzEwNTNkNDc5YzYyMzZlYjI2ZDExZGFkNWZhNTM4MQ==
6
+ ZjY3ZTk3ODIzODhhNzUwODI1ZmUzM2YzYWUxNDUzMzJlMDUzNWYyNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTU1NjYzNWRiYjVkMTdhOGUxOTUwODI2NzJmMTdkZDk3YWJkZTM2YmMxMGNh
10
- NjVjZTA2OTk3ZDRjMzc4NWRjZjI5OWJhZDRhNjBiOTYwMTgyNjIxMjgxOGRj
11
- NTQ0ZjIzOTYyZWE0YmNiZjQ1NDBiNDE1OGVmNzc0MTA0Y2ZhYzQ=
9
+ NDQyYzk2ZDQ3OGQwOWVmY2Q3Njk3M2FlNzgxYTQzNjBjZjIzYTc5YjI0MTMz
10
+ YWI5NjM0MmZiODU5YTI0NTBlMDA5NWM0Y2I0NzQ1N2FkNzMzZTUzNDgyMDVk
11
+ MGU2MzJkOGUzMThmODZmYjNlZTg2OTA2M2U3N2EwODQzMjg3MTk=
12
12
  data.tar.gz: !binary |-
13
- MWE4NThhNTEzNWNlMWMxMjhjNzY2ZDdjNDdmMGYxZjk3NjAzNjc5N2Q1N2Mx
14
- ZWUwMzE3NTFiZmEzYzdjNGM3MmE5ZjM4ZGNkN2IxYTgyNmNlNGI3MDhhNGFk
15
- Y2ViOWExMGU3MGQ4MGYxYmFmOWIzMDg0ZTlmOGMzMjA0ZTAyNTE=
13
+ ZDk3YmU4ZmM4OWEyOTRjMmVmNTI1MTc3Mzc4YTAwYTgzMzU4NzM4Y2VmZTQy
14
+ ZTc3YjNiYjQ3N2JmNGNjMDM4OTNmZmI4ODZlNWUxMzQ1ZWFiMzg4ODM4OTIy
15
+ MmJiYTg5MTU3MTZlNzA0ODhmNTFjNmE4NzIwMDlhYzlhYmE1MGY=
data/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [3.1.0] - 2016-05-15
9
+ ### Fixed
10
+ - check-instance-events.rb: Ignore completed instance-stop ec2 events
11
+ - check-instance-events.rb: Ignore canceled system-maintenance ec2 events
12
+
13
+ ## Added
14
+ - Added check-instance-reachability.rb: looks up all instances from a filter set and pings
15
+ - Added check-route.rb: checks a route to an instance / eni on a route table
16
+ - Added check-rds-pending.rb: checks for pending RDS maintenance events
17
+
18
+ ### Changed
19
+ - handler-ec2_node.rb updated to allow configuration set from client config
20
+ - metrics-ec2-filter.rb: Moved filter parsing to library
21
+ - update to Rubocop 0.40 and cleanup
22
+
8
23
  ## [3.0.0] - 2016-05-05
9
24
  ### Removed
10
25
  - Support for Ruby 2.0
@@ -183,13 +198,14 @@ WARNING: This release contains major breaking changes that will impact all user
183
198
  ### Added
184
199
  - initial release
185
200
 
186
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/3.0.0...HEAD
187
- [3.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/v2.4.3...3.0.0
188
- [2.4.3]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/v2.4.2...2.4.3
189
- [2.4.2]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/v2.4.1...2.4.2
190
- [2.4.1]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/v2.4.0...2.4.1
191
- [2.4.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/v2.3.0...2.4.0
192
- [2.3.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/v2.2.0...2.3.0
201
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/3.1.0...HEAD
202
+ [3.1.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/3.0.0...3.1.0
203
+ [3.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.4.3...3.0.0
204
+ [2.4.3]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.4.2...2.4.3
205
+ [2.4.2]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.4.1...2.4.2
206
+ [2.4.1]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.4.0...2.4.1
207
+ [2.4.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.3.0...2.4.0
208
+ [2.3.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.2.0...2.3.0
193
209
  [2.2.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/v2.1.1...2.2.0
194
210
  [2.1.1]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.1.0...v2.1.1
195
211
  [2.1.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.0.1...2.1.0
data/README.md CHANGED
@@ -62,6 +62,8 @@
62
62
 
63
63
  **check-rds-events.rb**
64
64
 
65
+ **check-rds-pending.rb**
66
+
65
67
  **check-rds.rb**
66
68
 
67
69
  **check-redshift-events.rb**
@@ -84,6 +86,8 @@
84
86
 
85
87
  **check_vpc_vpn.py**
86
88
 
89
+ **check-instances-count.rb**
90
+
87
91
  **check-vpc-vpn.rb**
88
92
 
89
93
  **handler-ec2_node.rb**
@@ -140,6 +144,7 @@
140
144
  * /bin/check-emr-steps.rb
141
145
  * /bin/check-instance-events.rb
142
146
  * /bin/check-rds-events.rb
147
+ * /bin/check-rds-pending.rb
143
148
  * /bin/check-rds.rb
144
149
  * /bin/check-redshift-events.rb
145
150
  * /bin/check-s3-object.rb
@@ -153,6 +158,7 @@
153
158
  * /bin/handler-ses.rb
154
159
  * /bin/handler-sns.rb
155
160
  * /bin/metrics-autoscaling-instance-count.rb
161
+ * /bin/check-instances-count.rb
156
162
  * /bin/metrics-ec2-count.rb
157
163
  * /bin/metrics-ec2-filter.rb
158
164
  * /bin/metrics-elasticache.rb
@@ -85,8 +85,7 @@ class CheckEc2CpuCredits < Sensu::Plugin::Check::CLI
85
85
  def aws_config
86
86
  { access_key_id: config[:aws_access_key],
87
87
  secret_access_key: config[:aws_secret_access_key],
88
- region: config[:aws_region]
89
- }
88
+ region: config[:aws_region] }
90
89
  end
91
90
 
92
91
  def asg
@@ -0,0 +1,112 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-beanstalk-health
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin checks the health of a beanstalk environment using
7
+ # the enhanced health reporting.
8
+ #
9
+ # OUTPUT:
10
+ # plain-text
11
+ #
12
+ # PLATFORMS:
13
+ # Linux
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: aws-sdk
17
+ # gem: sensu-plugin
18
+ #
19
+ # USAGE:
20
+ # ./check-beanstalk-health -e MyAppEnv
21
+ #
22
+ # NOTES:
23
+ #
24
+ # LICENSE:
25
+ # Brendan Leon Gibat
26
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
27
+ # for details.
28
+ #
29
+
30
+ require 'sensu-plugin/check/cli'
31
+ require 'aws-sdk'
32
+ require 'json'
33
+
34
+ class BeanstalkHealth < Sensu::Plugin::Check::CLI
35
+ option :environment,
36
+ description: 'Application environment name',
37
+ short: '-e ENVIRONMENT_NAME',
38
+ long: '--environment ENVIRONMENT_NAME',
39
+ required: true
40
+
41
+ option :no_data_ok,
42
+ short: '-n',
43
+ long: '--allow-no-data',
44
+ description: 'Returns unknown if health status is Grey. If set to false this will critical on a Grey status.',
45
+ boolean: true,
46
+ default: true
47
+
48
+ def env_health
49
+ @env_health ||= beanstalk_client
50
+ .describe_environment_health(
51
+ environment_name: config[:environment],
52
+ attribute_names: %w(Color Status HealthStatus Causes)
53
+ )
54
+ end
55
+
56
+ def beanstalk_client
57
+ @beanstalk_client ||= Aws::ElasticBeanstalk::Client.new
58
+ end
59
+
60
+ def instances_health
61
+ @instances_health ||= begin
62
+ curr_instances = beanstalk_client.describe_instances_health(
63
+ environment_name: config[:environment],
64
+ attribute_names: %w(Color HealthStatus Causes)
65
+ )
66
+ instances = curr_instances.instance_health_list
67
+ until curr_instances.next_token.nil?
68
+ curr_instances = beanstalk_client.describe_instances_health(
69
+ environment_name: config[:environment],
70
+ attribute_names: %w(Color HealthStatus Causes)
71
+ )
72
+ instances.concat(curr_instances.instance_health_list)
73
+ end
74
+ instances
75
+ end
76
+ end
77
+
78
+ def unhealthy_instances
79
+ @unhealthy_instances ||= instances_health.select { |i| i.color != 'Green' }
80
+ end
81
+
82
+ def status_rollup
83
+ "Beanstalk Status: #{env_health.status}, Health Status: #{env_health.health_status}, Causes: #{env_health.causes.join(', ')}"
84
+ end
85
+
86
+ def unhealthy_instance_description(instance)
87
+ "instance id: #{instance.instance_id}, color: #{instance.color}, health status: #{instance.health_status}, causes: [#{instance.causes.join(', ')}]"
88
+ end
89
+
90
+ def unhealthy_instances_rollup
91
+ "Unhealthy instances and causes: [ #{unhealthy_instances.collect { |i| unhealthy_instance_description(i) }.join(', ')} ]"
92
+ end
93
+
94
+ def run
95
+ color = env_health.color
96
+ if color == 'Green'
97
+ ok
98
+ elsif color == 'Yellow'
99
+ warning "Environment status is YELLOW. #{status_rollup} #{unhealthy_instances_rollup}"
100
+ elsif color == 'Red'
101
+ critical "Environment status is RED. #{status_rollup} #{unhealthy_instances_rollup}"
102
+ elsif color == 'Grey'
103
+ if config[:no_data_ok]
104
+ unknown "Environment status is GREY. This means NO DATA. #{status_rollup}"
105
+ else
106
+ critical "Environment status is GREY. This means NO DATA. #{status_rollup}"
107
+ end
108
+ else
109
+ critical "Unknown Environment status response, #{color}"
110
+ end
111
+ end
112
+ end
@@ -69,8 +69,7 @@ class CheckCertificateExpiry < Sensu::Plugin::Check::CLI
69
69
  def aws_config
70
70
  { access_key_id: config[:aws_access_key],
71
71
  secret_access_key: config[:aws_secret_access_key],
72
- region: config[:aws_region]
73
- }
72
+ region: config[:aws_region] }
74
73
  end
75
74
 
76
75
  def aws_client(opts = {})
@@ -73,8 +73,7 @@ class CloudWatchCheck < Sensu::Plugin::Check::CLI
73
73
  def aws_config
74
74
  { access_key_id: config[:aws_access_key],
75
75
  secret_access_key: config[:aws_secret_access_key],
76
- region: config[:aws_region]
77
- }
76
+ region: config[:aws_region] }
78
77
  end
79
78
 
80
79
  def run
@@ -99,8 +99,7 @@ class CheckDynamoDB < Sensu::Plugin::Check::CLI
99
99
  def aws_config
100
100
  { access_key_id: config[:aws_access_key],
101
101
  secret_access_key: config[:aws_secret_access_key],
102
- region: config[:aws_region]
103
- }
102
+ region: config[:aws_region] }
104
103
  end
105
104
 
106
105
  def dynamo_db
@@ -94,8 +94,7 @@ class CheckDynamoDB < Sensu::Plugin::Check::CLI
94
94
  def aws_config
95
95
  { access_key_id: config[:aws_access_key],
96
96
  secret_access_key: config[:aws_secret_access_key],
97
- region: config[:aws_region]
98
- }
97
+ region: config[:aws_region] }
99
98
  end
100
99
 
101
100
  def dynamo_db
@@ -80,7 +80,8 @@ class EC2CpuBalance < Sensu::Plugin::Check::CLI
80
80
  name: 'instance-state-name',
81
81
  values: ['running']
82
82
  }
83
- ])
83
+ ]
84
+ )
84
85
 
85
86
  messages = "\n"
86
87
  level = 0
@@ -84,8 +84,7 @@ class EC2Filter < Sensu::Plugin::Check::CLI
84
84
  def aws_config
85
85
  { access_key_id: config[:aws_access_key],
86
86
  secret_access_key: config[:aws_secret_access_key],
87
- region: config[:aws_region]
88
- }
87
+ region: config[:aws_region] }
89
88
  end
90
89
 
91
90
  def convert_operator
@@ -82,8 +82,7 @@ class CheckEc2Network < Sensu::Plugin::Check::CLI
82
82
  def aws_config
83
83
  { access_key_id: config[:aws_access_key],
84
84
  secret_access_key: config[:aws_secret_access_key],
85
- region: config[:aws_region]
86
- }
85
+ region: config[:aws_region] }
87
86
  end
88
87
 
89
88
  def ec2
@@ -82,8 +82,7 @@ class CheckELBCerts < Sensu::Plugin::Check::CLI
82
82
  def aws_config
83
83
  { access_key_id: config[:aws_access_key],
84
84
  secret_access_key: config[:aws_secret_access_key],
85
- region: config[:aws_region]
86
- }
85
+ region: config[:aws_region] }
87
86
  end
88
87
 
89
88
  def run
@@ -83,8 +83,7 @@ class ELBHealth < Sensu::Plugin::Check::CLI
83
83
  def aws_config
84
84
  { access_key_id: config[:aws_access_key],
85
85
  secret_access_key: config[:aws_secret_access_key],
86
- region: config[:aws_region]
87
- }
86
+ region: config[:aws_region] }
88
87
  end
89
88
 
90
89
  def run
@@ -75,8 +75,7 @@ class ELBHealth < Sensu::Plugin::Check::CLI
75
75
  def aws_config
76
76
  { access_key_id: config[:aws_access_key],
77
77
  secret_access_key: config[:aws_secret_access_key],
78
- region: config[:aws_region]
79
- }
78
+ region: config[:aws_region] }
80
79
  end
81
80
 
82
81
  def elb
@@ -90,8 +90,7 @@ class CheckELBLatency < Sensu::Plugin::Check::CLI
90
90
  def aws_config
91
91
  { access_key_id: config[:aws_access_key],
92
92
  secret_access_key: config[:aws_secret_access_key],
93
- region: config[:aws_region]
94
- }
93
+ region: config[:aws_region] }
95
94
  end
96
95
 
97
96
  def elb
@@ -90,8 +90,7 @@ class CheckELBNodes < Sensu::Plugin::Check::CLI
90
90
  def aws_config
91
91
  { access_key_id: config[:aws_access_key],
92
92
  secret_access_key: config[:aws_secret_access_key],
93
- region: config[:aws_region]
94
- }
93
+ region: config[:aws_region] }
95
94
  end
96
95
 
97
96
  def run
@@ -82,8 +82,7 @@ class CheckELBSumRequests < Sensu::Plugin::Check::CLI
82
82
  def aws_config
83
83
  { access_key_id: config[:aws_access_key],
84
84
  secret_access_key: config[:aws_secret_access_key],
85
- region: config[:aws_region]
86
- }
85
+ region: config[:aws_region] }
87
86
  end
88
87
 
89
88
  def elb
@@ -90,8 +90,7 @@ class CheckEMRCluster < Sensu::Plugin::Check::CLI
90
90
  def aws_config
91
91
  { access_key_id: config[:aws_access_key],
92
92
  secret_access_key: config[:aws_secret_access_key],
93
- region: config[:aws_region]
94
- }
93
+ region: config[:aws_region] }
95
94
  end
96
95
 
97
96
  def humanize(secs)
@@ -63,8 +63,7 @@ class CheckInstanceEvents < Sensu::Plugin::Check::CLI
63
63
  def aws_config
64
64
  { access_key_id: config[:aws_access_key],
65
65
  secret_access_key: config[:aws_secret_access_key],
66
- region: config[:aws_region]
67
- }
66
+ region: config[:aws_region] }
68
67
  end
69
68
 
70
69
  def run
@@ -91,7 +90,8 @@ class CheckInstanceEvents < Sensu::Plugin::Check::CLI
91
90
  # "not_after": "2015-01-05 18:00:00 UTC"
92
91
  # }
93
92
  # ]
94
- useful_events = i[:events_set].reject { |x| x[:code] == 'system-reboot' && x[:description] =~ /\[Completed\]/ }
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
95
  unless useful_events.empty?
96
96
  event_instances << i[:instance_id]
97
97
  end
@@ -0,0 +1,107 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-instance-reachability
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin looks up all instances from a filter set and pings
7
+ #
8
+ # OUTPUT:
9
+ # plain-text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: aws-sdk
16
+ # gem: sensu-plugin
17
+ #
18
+ # USAGE:
19
+ # #YELLOW
20
+ #
21
+ # NOTES:
22
+ #
23
+ # LICENSE:
24
+ # Copyright (c) 2014, Leon Gibat, brendan.gibat@gmail.com
25
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
26
+ # for details.
27
+ #
28
+
29
+ require 'sensu-plugin/check/cli'
30
+ require 'aws-sdk'
31
+ require 'sensu-plugins-aws'
32
+
33
+ class CheckInstanceReachability < Sensu::Plugin::Check::CLI
34
+ include Common
35
+ include Filter
36
+
37
+ option :aws_region,
38
+ short: '-r AWS_REGION',
39
+ long: '--aws-region REGION',
40
+ description: 'AWS Region (defaults to us-east-1).',
41
+ default: 'us-east-1'
42
+
43
+ option :filter,
44
+ short: '-f FILTER',
45
+ long: '--filter FILTER',
46
+ description: 'String representation of the filter to apply',
47
+ default: '{}'
48
+
49
+ option :timeout,
50
+ description: 'Ping timeout in seconds',
51
+ short: '-t TIMEOUT',
52
+ long: '--timeout TIMEOUT',
53
+ default: 5,
54
+ proc: proc(&:to_i)
55
+
56
+ option :count,
57
+ description: 'Ping count',
58
+ short: '-c COUNT',
59
+ long: '--count COUNT',
60
+ default: 1,
61
+ proc: proc(&:to_i)
62
+
63
+ option :critical_response,
64
+ description: 'Flag if the response should error on failures',
65
+ short: '-r',
66
+ long: '--critical-response',
67
+ boolean: true,
68
+ default: false
69
+
70
+ def run
71
+ begin
72
+ aws_config
73
+ client = Aws::EC2::Client.new
74
+
75
+ filter = Filter.parse(config[:filter])
76
+
77
+ options = { filters: filter }
78
+
79
+ errors = []
80
+ instance_ids = []
81
+ data = client.describe_instances(options)
82
+
83
+ data[:reservations].each do |res|
84
+ res[:instances].each do |i|
85
+ instance_ids << i[:instance_id]
86
+ `ping -c #{config[:count]} -W #{config[:timeout]} #{i[:private_ip_address]}`
87
+ if $CHILD_STATUS.to_i > 0
88
+ errors << "Could not reach #{i[:instance_id]}"
89
+ end
90
+ end
91
+ end
92
+ rescue => e
93
+ puts "Error: exception: #{e}"
94
+ critical
95
+ end
96
+ if errors.empty?
97
+ ok "Instances checked: #{instance_ids.join(',')}"
98
+ else
99
+ message = errors.join(',')
100
+ if config[:critical_response]
101
+ critical message
102
+ else
103
+ warning message
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,82 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-instances-count
4
+ #
5
+ #
6
+ # DESCRIPTION:
7
+ # This plugin checks the instances count for a specific auto scale group ( ASG ).
8
+ # Goal is to allow you to monitor that your ASG isnt out of control
9
+ #
10
+ # OUTPUT:
11
+ # plain-text
12
+ #
13
+ # PLATFORMS:
14
+ # Linux
15
+ #
16
+ # DEPENDENCIES:
17
+ # gem: aws-sdk
18
+ # gem: sensu-plugin
19
+ #
20
+ # USAGE:
21
+ # check-instances-count.rb --warn 15 --crit 25 --groupname logstash-instances-auto
22
+ #
23
+ #
24
+ #
25
+ # NOTES:
26
+ #
27
+ # LICENSE:
28
+ # Copyright (c) 2015, Kevin Bond
29
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
30
+ # for details.
31
+ #
32
+
33
+ require 'sensu-plugins-aws'
34
+ require 'sensu-plugin/check/cli'
35
+ require 'aws-sdk'
36
+
37
+ # Class to check the instance count
38
+ class CheckInstanceCount < Sensu::Plugin::Check::CLI
39
+ include Common
40
+
41
+ option :groupname,
42
+ description: 'Name of the AutoScaling group',
43
+ short: '-g GROUP_NAME',
44
+ long: '--groupname GROUP_NAME',
45
+ required: true
46
+
47
+ option :aws_region,
48
+ short: '-r AWS_REGION',
49
+ long: '--aws-region REGION',
50
+ description: 'AWS Region (such as us-east-1).',
51
+ default: 'us-east-1'
52
+
53
+ option :warn,
54
+ short: '-w COUNT',
55
+ long: '--warn COUNT',
56
+ proc: proc(&:to_i),
57
+ default: 15
58
+
59
+ option :crit,
60
+ short: '-c COUNT',
61
+ long: '--crit COUNT',
62
+ proc: proc(&:to_i),
63
+ default: 25
64
+
65
+ def instance_count
66
+ AWS::AutoScaling.new.groups[config[:groupname]].auto_scaling_instances.map(&:lifecycle_state).count('InService').to_i
67
+ rescue => e
68
+ critical "There was an error reaching AWS - #{e.message}"
69
+ end
70
+
71
+ def run
72
+ count = instance_count
73
+ msg_prefix = "#{count} instances running for ASG [ #{config[:groupname]} ]"
74
+ if count >= config[:crit]
75
+ critical "#{msg_prefix} - critical threshold #{config[:crit]}"
76
+ elsif count >= config[:warn]
77
+ warning "#{msg_prefix} - warning threshold #{config[:warn]}, critical threshold #{config[:crit]}"
78
+ else
79
+ ok msg_prefix
80
+ end
81
+ end
82
+ end
@@ -70,8 +70,7 @@ class CheckRDSEvents < Sensu::Plugin::Check::CLI
70
70
  def aws_config
71
71
  { access_key_id: config[:aws_access_key],
72
72
  secret_access_key: config[:aws_secret_access_key],
73
- region: config[:aws_region]
74
- }
73
+ region: config[:aws_region] }
75
74
  end
76
75
 
77
76
  def run
@@ -0,0 +1,67 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-rds-events
4
+ #
5
+ #
6
+ # DESCRIPTION:
7
+ # This plugin checks rds clusters for critical events.
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
11
+ #
12
+ # OUTPUT:
13
+ # plain-text
14
+ #
15
+ # PLATFORMS:
16
+ # Linux
17
+ #
18
+ # DEPENDENCIES:
19
+ # gem: aws-sdk
20
+ # gem: sensu-plugin
21
+ #
22
+ # USAGE:
23
+ # ./check-rds-events.rb -r ${you_region}
24
+ #
25
+ # NOTES:
26
+ #
27
+ # LICENSE:
28
+ # Tim Smith <tim@cozy.co>
29
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
30
+ # for details.
31
+ #
32
+
33
+ require 'sensu-plugin/check/cli'
34
+ require 'aws-sdk'
35
+
36
+ class CheckRDSEvents < Sensu::Plugin::Check::CLI
37
+ include Common
38
+
39
+ option :aws_region,
40
+ short: '-r AWS_REGION',
41
+ long: '--aws-region REGION',
42
+ description: 'AWS Region (such as eu-west-1).',
43
+ default: 'us-east-1'
44
+
45
+ def run
46
+ rds = Aws::RDS::Client.new
47
+
48
+ begin
49
+ # fetch all clusters identifiers
50
+ clusters = rds.describe_db_instances[:db_instances].map { |db| db[:db_instance_identifier] }
51
+ maint_clusters = []
52
+ # Check if there is any pending maintenance required
53
+ pending_record = rds.describe_pending_maintenance_actions(filters: [{ name: 'db-instance-id', values: clusters }])
54
+ pending_record[:pending_maintenance_actions].each do |response|
55
+ maint_clusters.push(response[:pending_maintenance_action_details])
56
+ end
57
+ rescue => e
58
+ unknown "An error occurred processing AWS RDS API: #{e.message}"
59
+ end
60
+
61
+ if maint_clusters.empty?
62
+ ok
63
+ else
64
+ critical("Clusters w/ pending maintenance required: #{maint_clusters.join(',')}")
65
+ end
66
+ end
67
+ end
data/bin/check-rds.rb CHANGED
@@ -124,8 +124,7 @@ class CheckRDS < Sensu::Plugin::Check::CLI
124
124
  def aws_config
125
125
  { access_key_id: config[:aws_access_key],
126
126
  secret_access_key: config[:aws_secret_access_key],
127
- region: config[:aws_region]
128
- }
127
+ region: config[:aws_region] }
129
128
  end
130
129
 
131
130
  def rds
@@ -66,8 +66,7 @@ class CheckRedshiftEvents < Sensu::Plugin::Check::CLI
66
66
  def aws_config
67
67
  { access_key_id: config[:aws_access_key],
68
68
  secret_access_key: config[:aws_secret_access_key],
69
- region: config[:aws_region]
70
- }
69
+ region: config[:aws_region] }
71
70
  end
72
71
 
73
72
  # setup a redshift connection using aws-sdk
@@ -0,0 +1,122 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-route
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin checks a route to an instance / eni on a route table
7
+ #
8
+ # OUTPUT:
9
+ # plain-text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: aws-sdk
16
+ # gem: sensu-plugin
17
+ #
18
+ # USAGE:
19
+ # #YELLOW
20
+ #
21
+ # NOTES:
22
+ #
23
+ # LICENSE:
24
+ # Copyright (c) 2014, Leon Gibat, brendan.gibat@gmail.com
25
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
26
+ # for details.
27
+ #
28
+
29
+ require 'sensu-plugin/check/cli'
30
+ require 'aws-sdk'
31
+ require 'sensu-plugins-aws'
32
+
33
+ class CheckRoute < Sensu::Plugin::Check::CLI
34
+ include Common
35
+ include Filter
36
+
37
+ option :aws_region,
38
+ short: '-r AWS_REGION',
39
+ long: '--aws-region REGION',
40
+ description: 'AWS Region (defaults to us-east-1).',
41
+ default: 'us-east-1'
42
+
43
+ option :filter,
44
+ short: '-f FILTER',
45
+ long: '--filter FILTER',
46
+ description: 'String representation of the filter to apply',
47
+ default: '{}'
48
+
49
+ option :network_interface_id,
50
+ description: 'Network interface id of route',
51
+ short: '-n NETWORK_INTERFACE_ID',
52
+ long: '--network-interface-id NETWORK_INTERFACE_ID',
53
+ default: ''
54
+
55
+ option :instance_id,
56
+ description: 'Instance Id attachment of route',
57
+ short: '-i INSTANCE_ID',
58
+ long: '--instance-id INSTANCE_ID',
59
+ default: ''
60
+
61
+ option :destination_cidr_block,
62
+ description: 'Destination CIDR block of route',
63
+ short: '-d DESTINATION_CIDR',
64
+ long: '--destination-cidr DESTINATION_CIDR',
65
+ default: ''
66
+
67
+ option :gateway_id,
68
+ description: 'Gateway Id of route',
69
+ short: '-g GATEWAY_ID',
70
+ long: '--gateway-id GATEWAY_ID',
71
+ default: ''
72
+
73
+ option :state,
74
+ description: 'The route state. Can be either "active" or "blackhole"',
75
+ short: '-s STATE',
76
+ long: '--state STATE',
77
+ default: 'active'
78
+
79
+ option :vpc_peering_id,
80
+ description: 'VPC peering connection id',
81
+ short: '-v VPC_PEERING_ID',
82
+ long: '--vpc-peering-id VPC_PEERING_ID',
83
+ default: ''
84
+
85
+ def run
86
+ begin
87
+ aws_config
88
+ client = Aws::EC2::Client.new
89
+
90
+ filter = Filter.parse(config[:filter])
91
+
92
+ options = { filters: filter }
93
+
94
+ data = client.describe_route_tables(options)
95
+
96
+ data[:route_tables].each do |rt|
97
+ rt[:routes].each do |route|
98
+ checks = true
99
+ if config[:state] != route[:state]
100
+ checks = false
101
+ elsif !config[:vpc_peering_id].empty? && config[:vpc_peering_id] != route[:vpc_peering_connection_id]
102
+ checks = false
103
+ elsif !config[:gateway_id].empty? && config[:gateway_id] != route[:gateway_id]
104
+ checks = false
105
+ elsif !config[:destination_cidr_block].empty? && config[:destination_cidr_block] != route[:destination_cidr_block]
106
+ checks = false
107
+ elsif !config[:instance_id].empty? && config[:instance_id] != route[:instance_id]
108
+ checks = false
109
+ elsif !config[:network_interface_id].empty? && config[:network_interface_id] != route[:network_interface_id]
110
+ checks = false
111
+ end
112
+ if checks
113
+ ok
114
+ end
115
+ end
116
+ end
117
+ rescue => e
118
+ critical "Error: exception: #{e}"
119
+ end
120
+ critical
121
+ end
122
+ end
@@ -62,8 +62,7 @@ class CheckS3Bucket < Sensu::Plugin::Check::CLI
62
62
  def aws_config
63
63
  { access_key_id: config[:aws_access_key],
64
64
  secret_access_key: config[:aws_secret_access_key],
65
- region: config[:aws_region]
66
- }
65
+ region: config[:aws_region] }
67
66
  end
68
67
 
69
68
  def run
@@ -87,8 +87,7 @@ class CheckS3Bucket < Sensu::Plugin::Check::CLI
87
87
  def aws_config
88
88
  { access_key_id: config[:aws_access_key],
89
89
  secret_access_key: config[:aws_secret_access_key],
90
- region: config[:aws_region]
91
- }
90
+ region: config[:aws_region] }
92
91
  end
93
92
 
94
93
  def run_check(type, age)
@@ -95,8 +95,7 @@ class SQSMsgs < Sensu::Plugin::Check::CLI
95
95
  def aws_config
96
96
  { access_key_id: config[:aws_access_key],
97
97
  secret_access_key: config[:aws_secret_access_key],
98
- region: config[:aws_region]
99
- }
98
+ region: config[:aws_region] }
100
99
  end
101
100
 
102
101
  def run
@@ -2,6 +2,8 @@
2
2
  #
3
3
  # CHANGELOG:
4
4
  # * 0.7.0:
5
+ # - Added method instance_id to check in client config section
6
+ # ['client']['aws']['instance_id'] first.
5
7
  # - Update to new API event naming and simplifying ec2_node_should_be_deleted method and fixing
6
8
  # match that will work with any user state defined.
7
9
  # * 0.6.0:
@@ -140,7 +142,7 @@ class Ec2Node < Sensu::Handler
140
142
  if ec2_node_should_be_deleted?
141
143
  delete_sensu_client!
142
144
  else
143
- puts "[EC2 Node] #{@event['client']['name']} is in an invalid state"
145
+ puts "[EC2 Node] #{instance_id} is in an invalid state"
144
146
  end
145
147
  end
146
148
 
@@ -150,6 +152,18 @@ class Ec2Node < Sensu::Handler
150
152
  deletion_status(response)
151
153
  end
152
154
 
155
+ 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
+ @event['client']['name']
165
+ end
166
+
153
167
  # Method to check if there is any insance and if instance is in a valid state that could be deleted
154
168
  def ec2_node_should_be_deleted?
155
169
  # Defining region for aws SDK object
@@ -160,7 +174,7 @@ class Ec2Node < Sensu::Handler
160
174
 
161
175
  begin
162
176
  # Finding the instance
163
- instances = ec2.describe_instances(instance_ids: [@event['client']['name']]).reservations[0]
177
+ instances = ec2.describe_instances(instance_ids: [instance_id]).reservations[0]
164
178
  # If instance is empty/nil instance id is not valid so client can be deleted
165
179
  if instances.nil? || instances.empty?
166
180
  true
@@ -63,8 +63,7 @@ class AutoScalingInstanceCountMetrics < Sensu::Plugin::Metric::CLI::Graphite
63
63
  def aws_config
64
64
  { access_key_id: config[:aws_access_key],
65
65
  secret_access_key: config[:aws_secret_access_key],
66
- region: config[:aws_region]
67
- }
66
+ region: config[:aws_region] }
68
67
  end
69
68
 
70
69
  def run
@@ -21,7 +21,7 @@
21
21
  # NOTES:
22
22
  #
23
23
  # LICENSE:
24
- # Copyright (c) 2014, Tim Smith, tim@cozy.co
24
+ # Copyright (c) 2014, Tim Smith, tsmith@chef.io
25
25
  # Released under the same terms as Sensu (the MIT license); see LICENSE
26
26
  # for details.
27
27
  #
@@ -63,8 +63,7 @@ class EC2Metrics < Sensu::Plugin::Metric::CLI::Graphite
63
63
  def aws_config
64
64
  { access_key_id: config[:aws_access_key],
65
65
  secret_access_key: config[:aws_secret_access_key],
66
- region: config[:aws_region]
67
- }
66
+ region: config[:aws_region] }
68
67
  end
69
68
 
70
69
  def by_instances_status(client)
@@ -29,21 +29,11 @@
29
29
 
30
30
  require 'sensu-plugin/metric/cli'
31
31
  require 'aws-sdk'
32
- require 'sensu-plugins-aws/filter'
32
+ require 'sensu-plugins-aws'
33
33
 
34
34
  class EC2Filter < Sensu::Plugin::Metric::CLI::Graphite
35
35
  include Filter
36
- option :aws_access_key,
37
- short: '-a AWS_ACCESS_KEY',
38
- long: '--aws-access-key AWS_ACCESS_KEY',
39
- description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
40
- default: ENV['AWS_ACCESS_KEY']
41
-
42
- option :aws_secret_access_key,
43
- short: '-k AWS_SECRET_KEY',
44
- long: '--aws-secret-access-key AWS_SECRET_KEY',
45
- description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
46
- default: ENV['AWS_SECRET_KEY']
36
+ include Common
47
37
 
48
38
  option :aws_region,
49
39
  short: '-r AWS_REGION',
@@ -72,8 +62,7 @@ class EC2Filter < Sensu::Plugin::Metric::CLI::Graphite
72
62
  def aws_config
73
63
  { access_key_id: config[:aws_access_key],
74
64
  secret_access_key: config[:aws_secret_access_key],
75
- region: config[:aws_region]
76
- }
65
+ region: config[:aws_region] }
77
66
  end
78
67
 
79
68
  def run
@@ -87,8 +87,7 @@ class ElastiCacheMetrics < Sensu::Plugin::Metric::CLI::Graphite
87
87
  def aws_config
88
88
  { access_key_id: config[:aws_access_key],
89
89
  secret_access_key: config[:aws_secret_access_key],
90
- region: config[:aws_region]
91
- }
90
+ region: config[:aws_region] }
92
91
  end
93
92
 
94
93
  def run
@@ -77,8 +77,7 @@ class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
77
77
  def aws_config
78
78
  { access_key_id: config[:aws_access_key],
79
79
  secret_access_key: config[:aws_secret_access_key],
80
- region: config[:aws_region]
81
- }
80
+ region: config[:aws_region] }
82
81
  end
83
82
 
84
83
  def run
data/bin/metrics-elb.rb CHANGED
@@ -89,8 +89,7 @@ class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
89
89
  def aws_config
90
90
  { access_key_id: config[:aws_access_key],
91
91
  secret_access_key: config[:aws_secret_access_key],
92
- region: config[:aws_region]
93
- }
92
+ region: config[:aws_region] }
94
93
  end
95
94
 
96
95
  def run
data/bin/metrics-sqs.rb CHANGED
@@ -70,8 +70,7 @@ class SQSMetrics < Sensu::Plugin::Metric::CLI::Graphite
70
70
  def aws_config
71
71
  { access_key_id: config[:aws_access_key],
72
72
  secret_access_key: config[:aws_secret_access_key],
73
- region: config[:aws_region]
74
- }
73
+ region: config[:aws_region] }
75
74
  end
76
75
 
77
76
  def scheme(queue_name)
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsAWS
2
2
  module Version
3
3
  MAJOR = 3
4
- MINOR = 0
4
+ MINOR = 1
5
5
  PATCH = 0
6
6
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.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-05-05 00:00:00.000000000 Z
11
+ date: 2016-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - ~>
186
186
  - !ruby/object:Gem::Version
187
- version: '0.37'
187
+ version: 0.40.0
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - ~>
193
193
  - !ruby/object:Gem::Version
194
- version: '0.37'
194
+ version: 0.40.0
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: rspec
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -229,6 +229,7 @@ email: <sensu-users@googlegroups.com>
229
229
  executables:
230
230
  - check-autoscaling-cpucredits.rb
231
231
  - check-beanstalk-elb-metric.rb
232
+ - check-beanstalk-health.rb
232
233
  - check-certificate-expiry.rb
233
234
  - check-cloudwatch-alarm.rb
234
235
  - check-cloudwatch-metric.rb
@@ -253,11 +254,15 @@ executables:
253
254
  - check-emr-steps.rb
254
255
  - check-instance-events.rb
255
256
  - check-instance-health.rb
257
+ - check-instance-reachability.rb
258
+ - check-instances-count.rb
256
259
  - check-kms-key.rb
257
260
  - check-rds-events.rb
261
+ - check-rds-pending.rb
258
262
  - check-rds.rb
259
263
  - check-redshift-events.rb
260
264
  - check-reserved-instances.rb
265
+ - check-route.rb
261
266
  - check-s3-bucket.rb
262
267
  - check-s3-object.rb
263
268
  - check-sensu-client.rb
@@ -290,6 +295,7 @@ files:
290
295
  - README.md
291
296
  - bin/check-autoscaling-cpucredits.rb
292
297
  - bin/check-beanstalk-elb-metric.rb
298
+ - bin/check-beanstalk-health.rb
293
299
  - bin/check-certificate-expiry.rb
294
300
  - bin/check-cloudwatch-alarm.rb
295
301
  - bin/check-cloudwatch-metric.rb
@@ -314,11 +320,15 @@ files:
314
320
  - bin/check-emr-steps.rb
315
321
  - bin/check-instance-events.rb
316
322
  - bin/check-instance-health.rb
323
+ - bin/check-instance-reachability.rb
324
+ - bin/check-instances-count.rb
317
325
  - bin/check-kms-key.rb
318
326
  - bin/check-rds-events.rb
327
+ - bin/check-rds-pending.rb
319
328
  - bin/check-rds.rb
320
329
  - bin/check-redshift-events.rb
321
330
  - bin/check-reserved-instances.rb
331
+ - bin/check-route.rb
322
332
  - bin/check-s3-bucket.rb
323
333
  - bin/check-s3-object.rb
324
334
  - bin/check-sensu-client.rb