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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9cece8a458614d75cb1de7e06e9ae6621f36d5b7
4
- data.tar.gz: a2f8aa1261f5129b66b91ba8a78baccb59ee6595
3
+ metadata.gz: 952cc6ac4588a8609b48d4aee965beb1bbc756bb
4
+ data.tar.gz: 54466ee9bf3f405efdcb215498f3111b4f6ec099
5
5
  SHA512:
6
- metadata.gz: 2c3ea581f55a1e0f2576a1f02dc7516ca01eaf43f41b0641a9a12a2ad4d90b72d6fb0900ba96c02e9cc07014113956f54ffd9197d6ddf85459196f83bccdbaf4
7
- data.tar.gz: f88cfd661753410f3b42efb94cc82818d281ab8fdf65d05d4b0b88e986ddeec65b733a291c7a183005b3c7c88b88cae5dfbb2cd492cb58ea8a37d677c5eea914
6
+ metadata.gz: 14cfd437258092ca503dab2ed8bbcb97472846184116354cf0cce2919f264d6b45bcb339b72b5ee5ed704ed0092d026550a647b42eea74b3175136f5d43c2ca4
7
+ data.tar.gz: 0759bf875abeefdb0629066e460a81c8d02c4d8980cbf72fc0e9180a4fe86950c9b1d58045fcd85229fc3e8f060f95ca46d66173dcbe9a944afdfe730861e464
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -3,7 +3,27 @@ This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
- ## Unreleased][unreleased]
6
+ ## [1.0.0] - 2015-07-22
7
+
8
+ WARNING: This release contains major breaking changes that will impact all users. The flags used for access key and secret key have been standardized accross all plugins resulting in changed flags for the majority of plugins. The new flags are -a AWS_ACCESS_KEY and -k AWS_SECRET_KEY.
9
+
10
+ ### Added
11
+ - EC2 node handler will now remove nodes terminated by a user
12
+ - Transitioned EC2 node handler from fog to aws sdk v2
13
+ - Allowed ignoring nil values returned from Cloudwatch in the check-rds plugin. Previously if Cloudwatch fell behind you would be alerted
14
+ - Added support for checking multiple ELB instances at once by passing a comma separated list of ELB instance names in metrics-elb-full.rb
15
+ - Added check-autoscaling-cpucredits.rb for checking T2 instances in autoscaling groups that are running low on CPU credits
16
+ - Updated the fog and aws-sdk gems to the latest versions to improve performance, reduce 3rd party gem dependencies, and add support for newer AWS features.
17
+
18
+ ### Fixed
19
+ - Renamed autoscaling-instance-count-metrics.rb -> metrics-autoscaling-instance-count.rb to match our naming scheme
20
+ - Reworked check-rds-events.rb to avoid the ABCSize warning from rubocop
21
+ - Corrected the list of plugins / files in the readme
22
+ - Make ELB name a required flag for the metrics ELB plugins to prevent nil class errors when it isn't provided
23
+ - Properly document that all plugins default to us-east-1 unless the region flag is passed
24
+ - Fix the ELB metrics plugins to properly use the passed auth data
25
+ - Fixed the metrics-elb-full plugin to still add the ELB instance name when a graphite schema is appended
26
+ - Fixed all plugins to support passing the AWS access and secret keys from shell variables. Plugin help listed this as an option for all plugins, but the support wasn't actually there.
7
27
 
8
28
  ## [0.0.4] - 2015-07-05
9
29
  ### Added
data/README.md CHANGED
@@ -9,14 +9,14 @@
9
9
 
10
10
  ## Functionality
11
11
 
12
- **check_vpc_vpn**
13
-
14
- **autoscaling-instance-count-metrics.rb**
12
+ **check-autoscaling-cpucredits.rb**
15
13
 
16
14
  **check-dynamodb-capacity.rb**
17
15
 
18
16
  **check-dynamodb-throttle.rb**
19
17
 
18
+ **check-ebs-snapshots.rb**
19
+
20
20
  **check-ec2-network.rb**
21
21
 
22
22
  **check-elb-certs.rb**
@@ -25,6 +25,8 @@
25
25
 
26
26
  **check-elb-health-sdk.rb**
27
27
 
28
+ **check-elb-health.rb**
29
+
28
30
  **check-elb-latency.rb**
29
31
 
30
32
  **check-elb-nodes.rb**
@@ -43,30 +45,35 @@
43
45
 
44
46
  **check-sqs-messages.rb**
45
47
 
46
- **ec2-count-metrics.rb**
48
+ **check_vpc_vpn.py**
49
+
50
+ **handler-ec2_node.rb**
51
+
52
+ **handler-sns.rb**
47
53
 
48
- **ec2-node.rb**
54
+ **metrics-autoscaling-instance-count.rb**
49
55
 
50
- **elasticache-metrics.rb**
56
+ **metrics-ec2-count.rb**
51
57
 
52
- **elb-full-metrics.rb**
58
+ **metrics-elasticache.rb**
53
59
 
54
- **elb-latency-metrics.rb**
60
+ **metrics-elb-full.rb**
55
61
 
56
- **elb-metrics.rb**
62
+ **metrics-elb.rb**
57
63
 
58
- **sqs-metrics.rb**
64
+ **metrics-sqs.rb**
59
65
 
60
66
  ## Files
61
67
 
62
- * /bin/check_vpc_vpn
63
- * /bin/autoscaling-instance-count-metrics.rb
68
+ * /bin/check-autoscaling-cpucredits.rb
64
69
  * /bin/check-dynamodb-capacity.rb
65
70
  * /bin/check-dynamodb-throttle.rb
71
+ * /bin/check-ebs-snapshots.rb
66
72
  * /bin/check-ec2-network.rb
67
73
  * /bin/check-elb-certs.rb
68
74
  * /bin/check-elb-health-fog.rb
69
75
  * /bin/check-elb-health-sdk.rb
76
+ * /bin/check-elb-health.rb
70
77
  * /bin/check-elb-latency.rb
71
78
  * /bin/check-elb-nodes.rb
72
79
  * /bin/check-elb-sum-requests.rb
@@ -76,11 +83,13 @@
76
83
  * /bin/check-redshift-events.rb
77
84
  * /bin/check-ses-limit.rb
78
85
  * /bin/check-sqs-messages.rb
86
+ * /bin/check_vpc_vpn.py
87
+ * /bin/handler-ec2_node.rb
88
+ * /bin/handler-sns.rb
89
+ * /bin/metrics-autoscaling-instance-count.rb
79
90
  * /bin/metrics-ec2-count.rb
80
- * /bin/handler-ec2-node.rb
81
91
  * /bin/metrics-elasticache.rb
82
92
  * /bin/metrics-elb-full.rb
83
- * /bin/metrics-elb-latency.rb
84
93
  * /bin/metrics-elb.rb
85
94
  * /bin/metrics-sqs.rb
86
95
 
@@ -0,0 +1,161 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-autoscaling-cpucredits
4
+ #
5
+ # DESCRIPTION:
6
+ # Check AutoScaling CPU Credits through CloudWatch API.
7
+ #
8
+ # OUTPUT:
9
+ # plain-text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: aws-sdk-v1
16
+ # gem: sensu-plugin
17
+ #
18
+ # USAGE:
19
+ # ./check-autoscaling-cpucredits.rb -r ${your_region} --warning-under 100 --critical-under 50
20
+ #
21
+ # NOTES:
22
+ # Based heavily on Yohei Kawahara's check-ec2-network
23
+ #
24
+ # LICENSE:
25
+ # Gavin Hamill <gavin@bashton.com>
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-v1'
32
+
33
+ class CheckEc2CpuCredits < Sensu::Plugin::Check::CLI
34
+ option :aws_access_key,
35
+ short: '-a AWS_ACCESS_KEY',
36
+ long: '--aws-access-key AWS_ACCESS_KEY',
37
+ description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
38
+ default: ENV['AWS_ACCESS_KEY']
39
+
40
+ option :aws_secret_access_key,
41
+ short: '-k AWS_SECRET_KEY',
42
+ long: '--aws-secret-access-key AWS_SECRET_KEY',
43
+ description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
44
+ default: ENV['AWS_SECRET_KEY']
45
+
46
+ option :aws_region,
47
+ short: '-r AWS_REGION',
48
+ long: '--aws-region REGION',
49
+ description: 'AWS Region (defaults to us-east-1).',
50
+ default: 'us-east-1'
51
+
52
+ option :group,
53
+ short: '-g G',
54
+ long: '--autoscaling-group GROUP',
55
+ description: 'AutoScaling group to check'
56
+
57
+ option :end_time,
58
+ short: '-t T',
59
+ long: '--end-time TIME',
60
+ default: Time.now,
61
+ description: 'CloudWatch metric statistics end time'
62
+
63
+ option :period,
64
+ short: '-p N',
65
+ long: '--period SECONDS',
66
+ default: 60,
67
+ description: 'CloudWatch metric statistics period'
68
+
69
+ option :countmetric,
70
+ short: '-d M',
71
+ long: '--countmetric METRIC',
72
+ default: 'CPUCreditBalance',
73
+ description: 'Select any CloudWatch _Count_ based metric (Status Checks / CPU Credits)'
74
+
75
+ option :warning_under,
76
+ short: '-w N',
77
+ long: '--warning-under VALUE',
78
+ description: 'Issue a warning if the CloudWatch _Count_ based metric (Status Check / CPU Credits) is below this value'
79
+
80
+ option :critical_under,
81
+ short: '-c N',
82
+ long: '--critical-under VALUE',
83
+ description: 'Issue a critical if the CloudWatch _Count_ based metric (Status Check / CPU Credits) is below this value'
84
+
85
+ def aws_config
86
+ { access_key_id: config[:aws_access_key],
87
+ secret_access_key: config[:aws_secret_access_key],
88
+ region: config[:aws_region]
89
+ }
90
+ end
91
+
92
+ def asg
93
+ @asg ||= AWS::AutoScaling.new aws_config
94
+ end
95
+
96
+ def cloud_watch
97
+ @cloud_watch ||= AWS::CloudWatch.new aws_config
98
+ end
99
+
100
+ def get_count_metric(group)
101
+ cloud_watch.metrics
102
+ .with_namespace('AWS/EC2')
103
+ .with_metric_name("#{config[:countmetric]}")
104
+ .with_dimensions(name: 'AutoScalingGroupName', value: group)
105
+ .first
106
+ end
107
+
108
+ def statistics_options
109
+ {
110
+ start_time: config[:end_time] - 600,
111
+ end_time: config[:end_time],
112
+ statistics: ['Average'],
113
+ period: config[:period]
114
+ }
115
+ end
116
+
117
+ def latest_value(metric)
118
+ value = metric.statistics(statistics_options.merge unit: 'Count')
119
+ value.datapoints[0][:average].to_f unless value.datapoints[0].nil?
120
+ end
121
+
122
+ def check_metric(group)
123
+ metric = get_count_metric group
124
+ latest_value metric
125
+ end
126
+
127
+ def check_group(group, reportstring, warnflag, critflag)
128
+ metric_value = check_metric group
129
+ if !metric_value.nil? && metric_value < config[:critical_under].to_f
130
+ critflag = 1
131
+ reportstring = reportstring + group + ': ' + metric_value.to_s + ' '
132
+ elsif !metric_value.nil? && metric_value < config[:warning_under].to_f
133
+ warnflag = 1
134
+ reportstring = reportstring + group + ': ' + metric_value.to_s + ' '
135
+ end
136
+ [reportstring, warnflag, critflag]
137
+ end
138
+
139
+ def run
140
+ warnflag = 0
141
+ critflag = 0
142
+ reportstring = ''
143
+ if config[:group].nil?
144
+ asg.groups.each do |group|
145
+ if group.desired_capacity > 0
146
+ reportstring, warnflag, critflag = check_group(group.name, reportstring, warnflag, critflag)
147
+ end
148
+ end
149
+ else
150
+ reportstring, warnflag, critflag = check_group(config[:group], reportstring, warnflag, critflag)
151
+ end
152
+
153
+ if critflag == 1
154
+ critical reportstring
155
+ elsif warnflag == 1
156
+ warning reportstring
157
+ else
158
+ ok 'All checked AutoScaling Groups are cool'
159
+ end
160
+ end
161
+ end
@@ -12,8 +12,7 @@
12
12
  # Linux
13
13
  #
14
14
  # DEPENDENCIES:
15
- # gem: aws-sdk
16
- # gem: time
15
+ # gem: aws-sdk-v1
17
16
  # gem: sensu-plugin
18
17
  #
19
18
  # USAGE:
@@ -36,20 +35,23 @@ require 'aws-sdk-v1'
36
35
  require 'time'
37
36
 
38
37
  class CheckDynamoDB < Sensu::Plugin::Check::CLI
39
- option :access_key_id,
40
- short: '-k N',
41
- long: '--access-key-id ID',
42
- description: 'AWS access key ID'
43
-
44
- option :secret_access_key,
45
- short: '-s N',
46
- long: '--secret-access-key KEY',
47
- description: 'AWS secret access key'
48
-
49
- option :region,
50
- short: '-r R',
51
- long: '--region REGION',
52
- description: 'AWS region'
38
+ option :aws_access_key,
39
+ short: '-a AWS_ACCESS_KEY',
40
+ long: '--aws-access-key AWS_ACCESS_KEY',
41
+ description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
42
+ default: ENV['AWS_ACCESS_KEY']
43
+
44
+ option :aws_secret_access_key,
45
+ short: '-k AWS_SECRET_KEY',
46
+ long: '--aws-secret-access-key AWS_SECRET_KEY',
47
+ description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
48
+ default: ENV['AWS_SECRET_KEY']
49
+
50
+ option :aws_region,
51
+ short: '-r AWS_REGION',
52
+ long: '--aws-region REGION',
53
+ description: 'AWS Region (defaults to us-east-1).',
54
+ default: 'us-east-1'
53
55
 
54
56
  option :table_names,
55
57
  short: '-t N',
@@ -95,10 +97,10 @@ class CheckDynamoDB < Sensu::Plugin::Check::CLI
95
97
  end
96
98
 
97
99
  def aws_config
98
- hash = {}
99
- 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]
100
- hash.update region: config[:region] if config[:region]
101
- hash
100
+ { access_key_id: config[:aws_access_key],
101
+ secret_access_key: config[:aws_secret_access_key],
102
+ region: config[:aws_region]
103
+ }
102
104
  end
103
105
 
104
106
  def dynamo_db
@@ -12,8 +12,7 @@
12
12
  # Linux
13
13
  #
14
14
  # DEPENDENCIES:
15
- # gem: aws-sdk
16
- # gem: time
15
+ # gem: aws-sdk-v1
17
16
  # gem: sensu-plugin
18
17
  #
19
18
  # USAGE:
@@ -33,20 +32,23 @@ require 'aws-sdk-v1'
33
32
  require 'time'
34
33
 
35
34
  class CheckDynamoDB < Sensu::Plugin::Check::CLI
36
- option :access_key_id,
37
- short: '-k N',
38
- long: '--access-key-id ID',
39
- description: 'AWS access key ID'
40
-
41
- option :secret_access_key,
42
- short: '-s N',
43
- long: '--secret-access-key KEY',
44
- description: 'AWS secret access key'
45
-
46
- option :region,
47
- short: '-r R',
48
- long: '--region REGION',
49
- description: 'AWS region'
35
+ option :aws_access_key,
36
+ short: '-a AWS_ACCESS_KEY',
37
+ long: '--aws-access-key AWS_ACCESS_KEY',
38
+ description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
39
+ default: ENV['AWS_ACCESS_KEY']
40
+
41
+ option :aws_secret_access_key,
42
+ short: '-k AWS_SECRET_KEY',
43
+ long: '--aws-secret-access-key AWS_SECRET_KEY',
44
+ description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
45
+ default: ENV['AWS_SECRET_KEY']
46
+
47
+ option :aws_region,
48
+ short: '-r AWS_REGION',
49
+ long: '--aws-region REGION',
50
+ description: 'AWS Region (defaults to us-east-1).',
51
+ default: 'us-east-1'
50
52
 
51
53
  option :table_names,
52
54
  short: '-t N',
@@ -90,10 +92,10 @@ class CheckDynamoDB < Sensu::Plugin::Check::CLI
90
92
  end
91
93
 
92
94
  def aws_config
93
- hash = {}
94
- 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]
95
- hash.update region: config[:region] if config[:region]
96
- hash
95
+ { access_key_id: config[:aws_access_key],
96
+ secret_access_key: config[:aws_secret_access_key],
97
+ region: config[:aws_region]
98
+ }
97
99
  end
98
100
 
99
101
  def dynamo_db
@@ -12,7 +12,7 @@
12
12
  # Linux
13
13
  #
14
14
  # DEPENDENCIES:
15
- # gem: aws-sdk
15
+ # gem: aws-sdk-v1
16
16
  # gem: sensu-plugin
17
17
  #
18
18
  # USAGE:
@@ -32,20 +32,23 @@ require 'sensu-plugin/check/cli'
32
32
  require 'aws-sdk-v1'
33
33
 
34
34
  class CheckEc2Network < Sensu::Plugin::Check::CLI
35
- option :access_key_id,
36
- short: '-k N',
37
- long: '--access-key-id ID',
38
- description: 'AWS access key ID'
39
-
40
- option :secret_access_key,
41
- short: '-s N',
42
- long: '--secret-access-key KEY',
43
- description: 'AWS secret access key'
44
-
45
- option :region,
46
- short: '-r R',
47
- long: '--region REGION',
48
- description: 'AWS region'
35
+ option :aws_access_key,
36
+ short: '-a AWS_ACCESS_KEY',
37
+ long: '--aws-access-key AWS_ACCESS_KEY',
38
+ description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
39
+ default: ENV['AWS_ACCESS_KEY']
40
+
41
+ option :aws_secret_access_key,
42
+ short: '-k AWS_SECRET_KEY',
43
+ long: '--aws-secret-access-key AWS_SECRET_KEY',
44
+ description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
45
+ default: ENV['AWS_SECRET_KEY']
46
+
47
+ option :aws_region,
48
+ short: '-r AWS_REGION',
49
+ long: '--aws-region REGION',
50
+ description: 'AWS Region (defaults to us-east-1).',
51
+ default: 'us-east-1'
49
52
 
50
53
  option :instance_id,
51
54
  short: '-i instance-id',
@@ -77,10 +80,10 @@ class CheckEc2Network < Sensu::Plugin::Check::CLI
77
80
  end
78
81
 
79
82
  def aws_config
80
- hash = {}
81
- 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]
82
- hash.update region: config[:region] if config[:region]
83
- hash
83
+ { access_key_id: config[:aws_access_key],
84
+ secret_access_key: config[:aws_secret_access_key],
85
+ region: config[:aws_region]
86
+ }
84
87
  end
85
88
 
86
89
  def ec2
@@ -106,10 +109,7 @@ class CheckEc2Network < Sensu::Plugin::Check::CLI
106
109
 
107
110
  def latest_value(metric)
108
111
  value = metric.statistics(statistics_options.merge unit: 'Bytes')
109
- # #YELLOW
110
- unless value.datapoints[0].nil? # rubocop:disable IfUnlessModifier, GuardClause
111
- value.datapoints[0][:average].to_f
112
- end
112
+ value.datapoints[0][:average].to_f unless value.datapoints[0].nil?
113
113
  end
114
114
 
115
115
  def check_metric(instance)