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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +21 -1
- data/README.md +23 -14
- data/bin/check-autoscaling-cpucredits.rb +161 -0
- data/bin/check-dynamodb-capacity.rb +22 -20
- data/bin/check-dynamodb-throttle.rb +22 -20
- data/bin/check-ec2-network.rb +23 -23
- data/bin/check-elb-certs.rb +12 -15
- data/bin/check-elb-health-fog.rb +11 -14
- data/bin/check-elb-health-sdk.rb +12 -14
- data/bin/check-elb-health.rb +6 -9
- data/bin/check-elb-latency.rb +23 -20
- data/bin/check-elb-nodes.rb +12 -11
- data/bin/check-elb-sum-requests.rb +22 -19
- data/bin/check-instance-events.rb +35 -36
- data/bin/check-rds-events.rb +31 -23
- data/bin/check-rds.rb +38 -25
- data/bin/check-redshift-events.rb +16 -12
- data/bin/check-ses-limit.rb +16 -10
- data/bin/check-sqs-messages.rb +13 -12
- data/bin/handler-ec2_node.rb +60 -37
- data/bin/{autoscaling-instance-count-metrics.rb → metrics-autoscaling-instance-count.rb} +12 -12
- data/bin/metrics-ec2-count.rb +64 -62
- data/bin/metrics-elasticache.rb +13 -12
- data/bin/metrics-elb-full.rb +17 -15
- data/bin/metrics-elb.rb +9 -8
- data/bin/metrics-sqs.rb +16 -11
- data/lib/sensu-plugins-aws/version.rb +2 -2
- metadata +14 -14
- metadata.gz.sig +0 -0
- data/bin/handler-ec2-node.rb +0 -156
@@ -1,6 +1,6 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# autoscaling-instance-count
|
3
|
+
# metrics-autoscaling-instance-count
|
4
4
|
#
|
5
5
|
# DESCRIPTION:
|
6
6
|
# Get a count of instances in a given AutoScaling group
|
@@ -12,10 +12,11 @@
|
|
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:
|
19
|
+
# #YELLOW
|
19
20
|
#
|
20
21
|
# NOTES:
|
21
22
|
#
|
@@ -44,27 +45,26 @@ class AutoScalingInstanceCountMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
44
45
|
option :aws_access_key,
|
45
46
|
short: '-a AWS_ACCESS_KEY',
|
46
47
|
long: '--aws-access-key AWS_ACCESS_KEY',
|
47
|
-
description: "AWS Access Key. Either set ENV['
|
48
|
+
description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
|
48
49
|
default: ENV['AWS_ACCESS_KEY']
|
49
50
|
|
50
51
|
option :aws_secret_access_key,
|
51
|
-
short: '-k
|
52
|
-
long: '--aws-secret-access-key
|
53
|
-
description: "AWS Secret Access Key. Either set ENV['
|
52
|
+
short: '-k AWS_SECRET_KEY',
|
53
|
+
long: '--aws-secret-access-key AWS_SECRET_KEY',
|
54
|
+
description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
|
54
55
|
default: ENV['AWS_SECRET_KEY']
|
55
56
|
|
56
57
|
option :aws_region,
|
57
58
|
short: '-r AWS_REGION',
|
58
59
|
long: '--aws-region REGION',
|
59
|
-
description: 'AWS Region (
|
60
|
+
description: 'AWS Region (defaults to us-east-1).',
|
60
61
|
default: 'us-east-1'
|
61
62
|
|
62
63
|
def aws_config
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
hash
|
64
|
+
{ access_key_id: config[:aws_access_key],
|
65
|
+
secret_access_key: config[:aws_secret_access_key],
|
66
|
+
region: config[:aws_region]
|
67
|
+
}
|
68
68
|
end
|
69
69
|
|
70
70
|
def run
|
data/bin/metrics-ec2-count.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# ec2-count-metrics
|
4
4
|
#
|
5
5
|
# DESCRIPTION:
|
6
|
-
# This plugin
|
6
|
+
# This plugin retrieves number of EC2 instances
|
7
7
|
#
|
8
8
|
# OUTPUT:
|
9
9
|
# plain-text
|
@@ -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:
|
@@ -39,17 +39,19 @@ class EC2Metrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
39
39
|
option :aws_access_key,
|
40
40
|
short: '-a AWS_ACCESS_KEY',
|
41
41
|
long: '--aws-access-key AWS_ACCESS_KEY',
|
42
|
-
description: "AWS Access Key. Either set ENV['
|
42
|
+
description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
|
43
|
+
default: ENV['AWS_ACCESS_KEY']
|
43
44
|
|
44
45
|
option :aws_secret_access_key,
|
45
|
-
short: '-k
|
46
|
-
long: '--aws-secret-access-key
|
47
|
-
description: "AWS Secret Access Key. Either set ENV['
|
46
|
+
short: '-k AWS_SECRET_KEY',
|
47
|
+
long: '--aws-secret-access-key AWS_SECRET_KEY',
|
48
|
+
description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
|
49
|
+
default: ENV['AWS_SECRET_KEY']
|
48
50
|
|
49
51
|
option :aws_region,
|
50
52
|
short: '-r AWS_REGION',
|
51
53
|
long: '--aws-region REGION',
|
52
|
-
description: 'AWS Region (
|
54
|
+
description: 'AWS Region (defaults to us-east-1).',
|
53
55
|
default: 'us-east-1'
|
54
56
|
|
55
57
|
option :type,
|
@@ -59,74 +61,74 @@ class EC2Metrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
59
61
|
default: 'instance'
|
60
62
|
|
61
63
|
def aws_config
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
{ access_key_id: config[:aws_access_key],
|
65
|
+
secret_access_key: config[:aws_secret_access_key],
|
66
|
+
region: config[:aws_region]
|
67
|
+
}
|
66
68
|
end
|
67
69
|
|
68
|
-
def
|
69
|
-
|
70
|
+
def by_instances_status(client)
|
71
|
+
if config[:scheme] == 'sensu.aws.ec2'
|
72
|
+
config[:scheme] += '.count'
|
73
|
+
end
|
70
74
|
|
71
|
-
|
75
|
+
options = { include_all_instances: true }
|
76
|
+
data = client.describe_instance_status(options)
|
72
77
|
|
73
|
-
|
74
|
-
|
75
|
-
config[:scheme] += '.count'
|
76
|
-
end
|
78
|
+
total = data[:instance_status_set].count
|
79
|
+
status = {}
|
77
80
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
data[:instance_status_set].each do |value|
|
86
|
-
stat = value[:instance_state][:name]
|
87
|
-
if status[stat].nil?
|
88
|
-
status[stat] = 1
|
89
|
-
else
|
90
|
-
status[stat] = status[stat] + 1
|
91
|
-
end
|
92
|
-
end
|
81
|
+
unless total.nil?
|
82
|
+
data[:instance_status_set].each do |value|
|
83
|
+
stat = value[:instance_state][:name]
|
84
|
+
if status[stat].nil?
|
85
|
+
status[stat] = 1
|
86
|
+
else
|
87
|
+
status[stat] = status[stat] + 1
|
93
88
|
end
|
89
|
+
end
|
90
|
+
end
|
94
91
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
end
|
101
|
-
end
|
92
|
+
unless data.nil? # rubocop: disable Style/GuardClause
|
93
|
+
# We only return data when we have some to return
|
94
|
+
output config[:scheme] + '.total', total
|
95
|
+
status.each do |name, count|
|
96
|
+
output config[:scheme] + ".#{name}", count
|
102
97
|
end
|
98
|
+
end
|
99
|
+
end
|
103
100
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
101
|
+
def by_instances_type(client)
|
102
|
+
if config[:scheme] == 'sensu.aws.ec2'
|
103
|
+
config[:scheme] += '.types'
|
104
|
+
end
|
108
105
|
|
109
|
-
|
110
|
-
|
111
|
-
instances = client.describe_instances
|
112
|
-
instances[:reservation_set].each do |i|
|
113
|
-
i[:instances_set].each do |instance|
|
114
|
-
type = instance[:instance_type]
|
115
|
-
if data[type].nil?
|
116
|
-
data[type] = 1
|
117
|
-
else
|
118
|
-
data[type] = data[type] + 1
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
106
|
+
data = {}
|
122
107
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
108
|
+
instances = client.describe_instances
|
109
|
+
instances[:reservation_set].each do |i|
|
110
|
+
i[:instances_set].each do |instance|
|
111
|
+
type = instance[:instance_type]
|
112
|
+
if data[type].nil?
|
113
|
+
data[type] = 1
|
114
|
+
else
|
115
|
+
data[type] = data[type] + 1
|
128
116
|
end
|
129
117
|
end
|
118
|
+
end
|
119
|
+
|
120
|
+
unless data.nil? # rubocop: disable Style/GuardClause
|
121
|
+
# We only return data when we have some to return
|
122
|
+
data.each do |name, count|
|
123
|
+
output config[:scheme] + ".#{name}", count
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def run
|
129
|
+
begin
|
130
|
+
|
131
|
+
client = AWS::EC2::Client.new aws_config
|
130
132
|
|
131
133
|
if config[:type] == 'instance'
|
132
134
|
by_instances_type(client)
|
data/bin/metrics-elasticache.rb
CHANGED
@@ -12,13 +12,12 @@
|
|
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
|
-
# needs example command
|
19
18
|
# USAGE:
|
20
19
|
# #YELLOW
|
21
|
-
|
20
|
+
#
|
22
21
|
# NOTES:
|
23
22
|
# Redis: http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CacheMetrics.Redis.html
|
24
23
|
# Memcached: http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CacheMetrics.Memcached.html
|
@@ -69,24 +68,26 @@ class ElastiCacheMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
69
68
|
option :aws_access_key,
|
70
69
|
short: '-a AWS_ACCESS_KEY',
|
71
70
|
long: '--aws-access-key AWS_ACCESS_KEY',
|
72
|
-
description: "AWS Access Key. Either set ENV['
|
71
|
+
description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
|
72
|
+
default: ENV['AWS_ACCESS_KEY']
|
73
73
|
|
74
74
|
option :aws_secret_access_key,
|
75
|
-
short: '-k
|
76
|
-
long: '--aws-secret-access-key
|
77
|
-
description: "AWS Secret Access Key. Either set ENV['
|
75
|
+
short: '-k AWS_SECRET_KEY',
|
76
|
+
long: '--aws-secret-access-key AWS_SECRET_KEY',
|
77
|
+
description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
|
78
|
+
default: ENV['AWS_SECRET_KEY']
|
78
79
|
|
79
80
|
option :aws_region,
|
80
81
|
short: '-r AWS_REGION',
|
81
82
|
long: '--aws-region REGION',
|
82
|
-
description: 'AWS Region (
|
83
|
+
description: 'AWS Region (defaults to us-east-1).',
|
83
84
|
default: 'us-east-1'
|
84
85
|
|
85
86
|
def aws_config
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
{ access_key_id: config[:aws_access_key],
|
88
|
+
secret_access_key: config[:aws_secret_access_key],
|
89
|
+
region: config[:aws_region]
|
90
|
+
}
|
90
91
|
end
|
91
92
|
|
92
93
|
def run
|
data/bin/metrics-elb-full.rb
CHANGED
@@ -12,6 +12,7 @@
|
|
12
12
|
# Linux
|
13
13
|
#
|
14
14
|
# DEPENDENCIES:
|
15
|
+
# gem: aws-sdk-v1
|
15
16
|
# gem: sensu-plugin
|
16
17
|
#
|
17
18
|
# USAGE:
|
@@ -37,9 +38,10 @@ require 'aws-sdk-v1'
|
|
37
38
|
|
38
39
|
class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
39
40
|
option :elbname,
|
40
|
-
description: 'Name of the Elastic Load Balancer',
|
41
|
+
description: 'Name of the Elastic Load Balancer (separate with commas for multiple ELBs)',
|
41
42
|
short: '-n ELB_NAME',
|
42
|
-
long: '--name ELB_NAME'
|
43
|
+
long: '--name ELB_NAME',
|
44
|
+
required: true
|
43
45
|
|
44
46
|
option :scheme,
|
45
47
|
description: 'Metric naming scheme, text to prepend to metric',
|
@@ -58,27 +60,25 @@ class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
58
60
|
short: '-a AWS_ACCESS_KEY',
|
59
61
|
long: '--aws-access-key AWS_ACCESS_KEY',
|
60
62
|
description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
|
61
|
-
required: true,
|
62
63
|
default: ENV['AWS_ACCESS_KEY']
|
63
64
|
|
64
65
|
option :aws_secret_access_key,
|
65
66
|
short: '-k AWS_SECRET_KEY',
|
66
67
|
long: '--aws-secret-access-key AWS_SECRET_KEY',
|
67
68
|
description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
|
68
|
-
required: true,
|
69
69
|
default: ENV['AWS_SECRET_KEY']
|
70
70
|
|
71
71
|
option :aws_region,
|
72
72
|
short: '-r AWS_REGION',
|
73
73
|
long: '--aws-region REGION',
|
74
|
-
description: 'AWS Region (
|
74
|
+
description: 'AWS Region (defaults to us-east-1).',
|
75
75
|
default: 'us-east-1'
|
76
76
|
|
77
77
|
def aws_config
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
{ access_key_id: config[:aws_access_key],
|
79
|
+
secret_access_key: config[:aws_secret_access_key],
|
80
|
+
region: config[:aws_region]
|
81
|
+
}
|
82
82
|
end
|
83
83
|
|
84
84
|
def run
|
@@ -109,7 +109,7 @@ class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
109
109
|
'dimensions' => [
|
110
110
|
{
|
111
111
|
'name' => 'LoadBalancerName',
|
112
|
-
'value' =>
|
112
|
+
'value' => nil
|
113
113
|
}
|
114
114
|
],
|
115
115
|
'start_time' => st.iso8601,
|
@@ -118,13 +118,15 @@ class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
118
118
|
}
|
119
119
|
|
120
120
|
result = {}
|
121
|
-
graphitepath = config[:scheme]
|
122
121
|
|
123
|
-
config[:elbname].split('
|
122
|
+
config[:elbname].split(',').each do |elbname|
|
123
|
+
if config[:scheme] == ''
|
124
|
+
graphitepath = "#{elbname}"
|
125
|
+
else
|
126
|
+
graphitepath = "#{config[:scheme]}.#{elbname}"
|
127
|
+
end
|
128
|
+
|
124
129
|
statistic_type.each do |key, value|
|
125
|
-
if config[:scheme] == ''
|
126
|
-
graphitepath = "#{config[:elbname]}.#{key.downcase}"
|
127
|
-
end
|
128
130
|
options['metric_name'] = key
|
129
131
|
options['dimensions'][0]['value'] = elbname
|
130
132
|
options['statistics'] = [value]
|
data/bin/metrics-elb.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# elb-
|
3
|
+
# elb-metrics
|
4
4
|
#
|
5
5
|
# DESCRIPTION:
|
6
6
|
# Gets latency metrics from CloudWatch and puts them in Graphite for longer term storage
|
@@ -12,6 +12,7 @@
|
|
12
12
|
# Linux
|
13
13
|
#
|
14
14
|
# DEPENDENCIES:
|
15
|
+
# gem: aws-sdk-v1
|
15
16
|
# gem: sensu-plugin
|
16
17
|
#
|
17
18
|
# USAGE:
|
@@ -39,7 +40,8 @@ class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
39
40
|
option :elbname,
|
40
41
|
description: 'Name of the Elastic Load Balancer',
|
41
42
|
short: '-n ELB_NAME',
|
42
|
-
long: '--name ELB_NAME'
|
43
|
+
long: '--name ELB_NAME',
|
44
|
+
required: true
|
43
45
|
|
44
46
|
option :scheme,
|
45
47
|
description: 'Metric naming scheme, text to prepend to metric',
|
@@ -81,18 +83,17 @@ class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
81
83
|
option :aws_region,
|
82
84
|
short: '-r AWS_REGION',
|
83
85
|
long: '--aws-region REGION',
|
84
|
-
description: 'AWS Region (
|
86
|
+
description: 'AWS Region (defaults to us-east-1).',
|
85
87
|
default: 'us-east-1'
|
86
88
|
|
87
89
|
def aws_config
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
{ access_key_id: config[:aws_access_key],
|
91
|
+
secret_access_key: config[:aws_secret_access_key],
|
92
|
+
region: config[:aws_region]
|
93
|
+
}
|
92
94
|
end
|
93
95
|
|
94
96
|
def run
|
95
|
-
statistic = ''
|
96
97
|
if config[:statistic] == ''
|
97
98
|
default_statistic_per_metric = {
|
98
99
|
'Latency' => 'Average',
|
data/bin/metrics-sqs.rb
CHANGED
@@ -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:
|
@@ -43,21 +43,30 @@ class SQSMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
43
43
|
default: ''
|
44
44
|
|
45
45
|
option :aws_access_key,
|
46
|
-
description: "AWS Access Key. Either set ENV['
|
46
|
+
description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
|
47
47
|
short: '-a AWS_ACCESS_KEY',
|
48
|
-
long: '--aws-access-key AWS_ACCESS_KEY'
|
48
|
+
long: '--aws-access-key AWS_ACCESS_KEY',
|
49
|
+
default: ENV['AWS_ACCESS_KEY']
|
49
50
|
|
50
51
|
option :aws_secret_access_key,
|
51
52
|
description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_ACCESS_KEY'] or provide it as an option",
|
52
|
-
short: '-k
|
53
|
-
long: '--aws-secret-access-key
|
53
|
+
short: '-k AWS_SECRET_KEY',
|
54
|
+
long: '--aws-secret-access-key AWS_SECRET_KEY',
|
55
|
+
default: ENV['AWS_SECRET_KEY']
|
54
56
|
|
55
57
|
option :aws_region,
|
56
|
-
description: 'AWS Region (
|
58
|
+
description: 'AWS Region (defaults to us-east-1).',
|
57
59
|
short: '-r AWS_REGION',
|
58
60
|
long: '--aws-region AWS_REGION',
|
59
61
|
default: 'us-east-1'
|
60
62
|
|
63
|
+
def aws_config
|
64
|
+
{ access_key_id: config[:aws_access_key],
|
65
|
+
secret_access_key: config[:aws_secret_access_key],
|
66
|
+
region: config[:aws_region]
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
61
70
|
def run
|
62
71
|
if config[:scheme] == ''
|
63
72
|
scheme = "aws.sqs.queue.#{config[:queue].gsub('-', '_')}.message_count"
|
@@ -66,11 +75,7 @@ class SQSMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
66
75
|
end
|
67
76
|
|
68
77
|
begin
|
69
|
-
sqs = AWS::SQS.new
|
70
|
-
access_key_id: config[:aws_access_key],
|
71
|
-
secret_access_key: config[:aws_secret_access_key],
|
72
|
-
region: config[:aws_region]
|
73
|
-
)
|
78
|
+
sqs = AWS::SQS.new aws_config
|
74
79
|
|
75
80
|
messages = sqs.queues.named(config[:queue]).approximate_number_of_messages
|
76
81
|
output scheme, messages
|