sensu-plugins-aws 2.1.1 → 2.2.0
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 +8 -8
- data/CHANGELOG.md +16 -3
- data/README.md +3 -0
- data/bin/check-ebs-snapshots.rb +15 -5
- data/bin/check-elasticache-failover.rb +113 -0
- data/bin/check-rds-events.rb +26 -3
- data/bin/check-rds.rb +5 -5
- data/bin/check-sensu-client.rb +175 -0
- data/bin/check-sqs-messages.rb +47 -9
- data/bin/check-trustedadvisor-service-limits.rb +82 -0
- data/bin/metrics-elasticache.rb +16 -3
- data/bin/metrics-sqs.rb +32 -11
- data/lib/sensu-plugins-aws/version.rb +2 -2
- metadata +9 -35
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGMyOTMzMDljMzFjOTExZTdkZDhkOWNkOGUyN2I4ZjY1Yzk0MTRmNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzAyNzdkM2EwOWM0M2YzOTdjZGViOTMyMWRmMjg1Zjc4NGQ1OTEwNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGJhNjQ5ODEwZDZiMTUxNmFkOWQxNzZjODJjZGI2YmNlMDk2NGY3Zjc2YmQ3
|
10
|
+
ZDA1ZDQwNWE0Y2IxZTBhNzUwZjYyZDdkYzk3NzMxMzhkOWNkOTY3MzNlYTI2
|
11
|
+
OWYwYzBhZTVmMTFkNjU1MzU5Y2UyMjdlOTNmMDExZjg2MzE4OTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjE1NDA1Mzc0NjdlNDYxMWJjZWM5OWJjYzBlZDI4NGNjODMyOTI1OGQyYTFl
|
14
|
+
ZTllNzBkODViMWMyNzA0MzEyZDQwYjY4YjkzNTc4YTNmYTZlZTgwMWRkNTg4
|
15
|
+
ZjE1NjY2NmNhNThhZmU1YjIwODRhNjM0YzhjMDk3ODBlZGFhOTU=
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,19 @@ 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
|
6
|
+
## [Unreleased]
|
7
|
+
|
8
|
+
## [2.2.0] - 2016-02-25
|
9
|
+
### Added
|
10
|
+
- check-ebs-snapshots.rb: added -i flag to ignore volumes with an IGNORE_BACKUP tag
|
11
|
+
- check-sensu-client.rb Ensures that ec2 instances are registered with Sensu.
|
12
|
+
- check-trustedadvisor-service-limits.rb: New check for service limits based on Trusted Advisor API
|
13
|
+
- check-sqs-messages.rb,metrics-sqs.rb: Allow specifying queues by prefix with -p option
|
14
|
+
- check-rds-events.rb: Add option to check a specific RDS instance
|
15
|
+
- Add plugin check-elasticache-failover.rb that checks if an Elasticache node is in the primary state
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
- metrics-elasticache.rb: Gather node metrics when requested
|
7
19
|
|
8
20
|
## [2.1.1] - 2016-02-05
|
9
21
|
### Added
|
@@ -124,8 +136,9 @@ WARNING: This release contains major breaking changes that will impact all user
|
|
124
136
|
### Added
|
125
137
|
- initial release
|
126
138
|
|
127
|
-
[
|
128
|
-
[2.
|
139
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.2.0...HEAD
|
140
|
+
[2.2.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/v2.1.1...2.2.0
|
141
|
+
[2.1.1]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.1.0...v2.1.1
|
129
142
|
[2.1.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.0.1...2.1.0
|
130
143
|
[2.0.1]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/2.0.0...2.0.1
|
131
144
|
[2.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/1.2.0...2.0.0
|
data/README.md
CHANGED
@@ -30,6 +30,8 @@
|
|
30
30
|
|
31
31
|
**check-eip-allocation.rb**
|
32
32
|
|
33
|
+
**check-elasticache-failover.rb**
|
34
|
+
|
33
35
|
**check-elb-certs.rb**
|
34
36
|
|
35
37
|
**check-elb-health-fog.rb**
|
@@ -102,6 +104,7 @@
|
|
102
104
|
* /bin/check-ebs-snapshots.rb
|
103
105
|
* /bin/check-ec2-filter.rb
|
104
106
|
* /bin/check-ec2-network.rb
|
107
|
+
* /bin/check-elasticache-failover.rb
|
105
108
|
* /bin/check-elb-certs.rb
|
106
109
|
* /bin/check-elb-health-fog.rb
|
107
110
|
* /bin/check-elb-health-sdk.rb
|
data/bin/check-ebs-snapshots.rb
CHANGED
@@ -18,8 +18,12 @@
|
|
18
18
|
# USAGE:
|
19
19
|
# ./check-ebs-snapshots.rb -r ${you_region}
|
20
20
|
# ./check-ebs-snapshots.rb -r ${you_region} -p 1
|
21
|
+
# ./check-ebs-snapshots.rb -r ${you_region} -p -i
|
22
|
+
# ./check-ebs-snapshots.rb -r ${you_region} -i
|
21
23
|
#
|
22
24
|
# NOTES:
|
25
|
+
# When using -i flag any volume that has a tag-key of "IGNORE_BACKUP" will
|
26
|
+
# be ignored.
|
23
27
|
#
|
24
28
|
# LICENSE:
|
25
29
|
# Shane Starcher <shane.starcher@gmail.com>
|
@@ -45,11 +49,18 @@ class CheckEbsSnapshots < Sensu::Plugin::Check::CLI
|
|
45
49
|
description: 'AWS region',
|
46
50
|
default: 'us-east-1'
|
47
51
|
|
52
|
+
option :check_ignored,
|
53
|
+
short: '-i',
|
54
|
+
long: '--ignore',
|
55
|
+
description: 'mark as true to ignore volumes with an IGNORE_BACKUP tag',
|
56
|
+
default: false,
|
57
|
+
boolean: true
|
58
|
+
|
48
59
|
def run
|
49
60
|
errors = []
|
50
|
-
ec2 = Aws::EC2::Client.new
|
61
|
+
@ec2 = Aws::EC2::Client.new
|
51
62
|
|
52
|
-
volumes = ec2.describe_volumes(
|
63
|
+
volumes = @ec2.describe_volumes(
|
53
64
|
filters: [
|
54
65
|
{
|
55
66
|
name: 'attachment.status',
|
@@ -61,11 +72,10 @@ class CheckEbsSnapshots < Sensu::Plugin::Check::CLI
|
|
61
72
|
}
|
62
73
|
]
|
63
74
|
)
|
64
|
-
|
65
75
|
volumes[:volumes].each do |volume|
|
66
76
|
tags = volume[:tags].map { |a| Hash[*a] }.reduce(:merge) || {}
|
67
|
-
|
68
|
-
snapshots = ec2.describe_snapshots(
|
77
|
+
next if config[:check_ignored] && tags.key?('IGNORE_BACKUP')
|
78
|
+
snapshots = @ec2.describe_snapshots(
|
69
79
|
filters: [
|
70
80
|
{
|
71
81
|
name: 'volume-id',
|
@@ -0,0 +1,113 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-elasticache-failover.rb
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Checks if specified ElastiCache node is `primary` state.
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# CheckElastiCacheFailover OK: Node `mynode-001` (in replication group `my-group-1`, node group `0001`) is `primary`.
|
10
|
+
# or
|
11
|
+
# CheckElastiCacheFailover CRITICAL: Node `mynode-001` (in replication group `my-group-1`, node group `0001`) is **not** `primary`.
|
12
|
+
#
|
13
|
+
# PLATFORMS:
|
14
|
+
# Linux, Windows, BSD, Solaris, etc
|
15
|
+
#
|
16
|
+
# DEPENDENCIES:
|
17
|
+
# gem: sensu-plugin
|
18
|
+
# gem: aws-sdk >= 2
|
19
|
+
#
|
20
|
+
# USAGE:
|
21
|
+
# check-elasticache-failover.rb --region <your region> --replication-group <yours> --node-group <yours> --primary-node <yours>
|
22
|
+
#
|
23
|
+
# NOTES:
|
24
|
+
#
|
25
|
+
# LICENSE:
|
26
|
+
# y13i <email@y13i.com>
|
27
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
28
|
+
# for details.
|
29
|
+
#
|
30
|
+
|
31
|
+
require 'sensu-plugin/check/cli'
|
32
|
+
require 'aws-sdk'
|
33
|
+
require 'sensu-plugins-aws/common'
|
34
|
+
|
35
|
+
class CheckElastiCacheFailover < Sensu::Plugin::Check::CLI
|
36
|
+
VERSION = '0.0.1'.freeze
|
37
|
+
|
38
|
+
option :profile,
|
39
|
+
description: 'Profile name of AWS shared credential file entry.',
|
40
|
+
long: '--profile PROFILE',
|
41
|
+
short: '-p PROFILE'
|
42
|
+
|
43
|
+
option :aws_region,
|
44
|
+
description: 'AWS region.',
|
45
|
+
short: '-r REGION',
|
46
|
+
long: '--region REGION'
|
47
|
+
|
48
|
+
option :severity,
|
49
|
+
description: 'Critical or Warning.',
|
50
|
+
short: '-s SEVERITY',
|
51
|
+
long: '--severity SEVERITY',
|
52
|
+
proc: :intern.to_proc,
|
53
|
+
default: :critical
|
54
|
+
|
55
|
+
option :replication_group,
|
56
|
+
description: 'Replication group to check.',
|
57
|
+
long: '--replication-group ID',
|
58
|
+
short: '-g ID'
|
59
|
+
|
60
|
+
option :node_group,
|
61
|
+
description: 'Node group to check.',
|
62
|
+
long: '--node-group ID',
|
63
|
+
short: '-n ID'
|
64
|
+
|
65
|
+
option :primary_node,
|
66
|
+
description: 'Cluster name that should be primary.',
|
67
|
+
long: '--primary-node NAME',
|
68
|
+
short: '-c NAME'
|
69
|
+
|
70
|
+
include Common
|
71
|
+
|
72
|
+
def run
|
73
|
+
replication_group = elasticache.client.describe_replication_groups.replication_groups.find do |g|
|
74
|
+
g.replication_group_id == config[:replication_group]
|
75
|
+
end
|
76
|
+
|
77
|
+
unknown 'Replication group not found.' if replication_group.nil?
|
78
|
+
|
79
|
+
node_group = replication_group.node_groups.find do |g|
|
80
|
+
g.node_group_id == config[:node_group]
|
81
|
+
end
|
82
|
+
|
83
|
+
unknown 'Node group not found.' if node_group.nil?
|
84
|
+
|
85
|
+
node = node_group.node_group_members.find do |n|
|
86
|
+
n.cache_cluster_id == config[:primary_node]
|
87
|
+
end
|
88
|
+
|
89
|
+
unknown 'Node not found.' if node.nil?
|
90
|
+
|
91
|
+
message = "Node `#{config[:primary_node]}` (in replication group `#{config[:replication_group]}`, node group `#{config[:node_group]}`) is "
|
92
|
+
|
93
|
+
if node.current_role == 'primary'
|
94
|
+
message += '`primary`.'
|
95
|
+
ok message
|
96
|
+
else
|
97
|
+
message += '**not** `primary`.'
|
98
|
+
send config[:severity], message
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def elasticache
|
105
|
+
return @elasticache if @elasticache
|
106
|
+
|
107
|
+
c = {}
|
108
|
+
c.update aws_config
|
109
|
+
c.update(profile: config[:profile]) if config[:profile]
|
110
|
+
|
111
|
+
@elasticache = Aws::ElastiCache::Resource.new(c)
|
112
|
+
end
|
113
|
+
end
|
data/bin/check-rds-events.rb
CHANGED
@@ -23,7 +23,14 @@
|
|
23
23
|
# gem: sensu-plugin
|
24
24
|
#
|
25
25
|
# USAGE:
|
26
|
-
#
|
26
|
+
# Check's a specific RDS instance in a specific region for critical events
|
27
|
+
# check-rds-events.rb -r ${your_region} -k ${your_aws_secret_access_key} -a ${your_aws_access_key} -i ${your_rds_instance_id_name}
|
28
|
+
#
|
29
|
+
# Checks all RDS instances in a specific region
|
30
|
+
# check-rds-events.rb -r ${your_region} -k ${your_aws_secret_access_key} -a ${your_aws_access_key}
|
31
|
+
#
|
32
|
+
# Checks all RDS instances in a specific region, should be using IAM role
|
33
|
+
# check-rds-events.rb -r ${your_region}
|
27
34
|
#
|
28
35
|
# NOTES:
|
29
36
|
#
|
@@ -55,6 +62,11 @@ class CheckRDSEvents < Sensu::Plugin::Check::CLI
|
|
55
62
|
description: 'AWS Region (defaults to us-east-1).',
|
56
63
|
default: 'us-east-1'
|
57
64
|
|
65
|
+
option :db_instance_id,
|
66
|
+
short: '-i N',
|
67
|
+
long: '--db-instance-id NAME',
|
68
|
+
description: 'DB instance identifier'
|
69
|
+
|
58
70
|
def aws_config
|
59
71
|
{ access_key_id: config[:aws_access_key],
|
60
72
|
secret_access_key: config[:aws_secret_access_key],
|
@@ -75,8 +87,18 @@ class CheckRDSEvents < Sensu::Plugin::Check::CLI
|
|
75
87
|
rds = AWS::RDS::Client.new aws_config
|
76
88
|
|
77
89
|
begin
|
78
|
-
|
79
|
-
|
90
|
+
if !config[:db_instance_id].nil? && !config[:db_instance_id].empty?
|
91
|
+
db_instance = rds.describe_db_instances(db_instance_identifier: config[:db_instance_id])
|
92
|
+
if db_instance.nil? || db_instance.empty?
|
93
|
+
unknown "#{config[:db_instance_id]} instance not found"
|
94
|
+
else
|
95
|
+
clusters = [config[:db_instance_id]]
|
96
|
+
end
|
97
|
+
else
|
98
|
+
# fetch all clusters identifiers
|
99
|
+
clusters = rds.describe_db_instances[:db_instances].map { |db| db[:db_instance_identifier] }
|
100
|
+
end
|
101
|
+
|
80
102
|
maint_clusters = []
|
81
103
|
|
82
104
|
# fetch the last 15 minutes of events for each cluster
|
@@ -96,6 +118,7 @@ class CheckRDSEvents < Sensu::Plugin::Check::CLI
|
|
96
118
|
cluster_name_long = "#{cluster_name} (#{aws_config[:region]}) #{events_record[:events][-1][:message]}"
|
97
119
|
maint_clusters.push(cluster_name_long)
|
98
120
|
end
|
121
|
+
|
99
122
|
rescue => e
|
100
123
|
unknown "An error occurred processing AWS RDS API: #{e.message}"
|
101
124
|
end
|
data/bin/check-rds.rb
CHANGED
@@ -134,8 +134,8 @@ class CheckRDS < Sensu::Plugin::Check::CLI
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def find_db_instance(id)
|
137
|
-
db = rds.describe_db_instances.db_instances.
|
138
|
-
unknown 'DB instance not found.' if db.
|
137
|
+
db = rds.describe_db_instances.db_instances.detect { |db_instance| db_instance.db_instance_identifier == id }
|
138
|
+
unknown 'DB instance not found.' if db.nil?
|
139
139
|
db
|
140
140
|
end
|
141
141
|
|
@@ -146,7 +146,7 @@ class CheckRDS < Sensu::Plugin::Check::CLI
|
|
146
146
|
dimensions: [
|
147
147
|
{
|
148
148
|
name: 'DBInstanceIdentifier',
|
149
|
-
value: @db_instance.
|
149
|
+
value: @db_instance.db_instance_identifier
|
150
150
|
}
|
151
151
|
],
|
152
152
|
start_time: config[:end_time] - config[:period],
|
@@ -240,8 +240,8 @@ class CheckRDS < Sensu::Plugin::Check::CLI
|
|
240
240
|
end
|
241
241
|
|
242
242
|
def check_connections(severity, expected_lower_than)
|
243
|
-
@connections_metric ||= cloud_watch_metric 'DatabaseConnections'
|
244
|
-
@connections_metric_value ||= latest_value @connections_metric
|
243
|
+
@connections_metric ||= cloud_watch_metric 'DatabaseConnections', 'Count'
|
244
|
+
@connections_metric_value ||= latest_value @connections_metric
|
245
245
|
return if @connections_metric_value < expected_lower_than
|
246
246
|
flag_alert severity, "; DatabaseConnections are #{sprintf '%d', @connections_metric_value} (expected lower than #{expected_lower_than})"
|
247
247
|
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# sensu-health-check
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Finds a given tag set from EC2 and ensures sensu clients exist
|
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
|
+
# ./check-sensu-client.rb -w 20 -f "{name:tag-value,values:[infrastructure]}"
|
20
|
+
# ./check-sensu-client.rb -w 20 -f "{name:tag-value,values:[infrastructure]}" -e '{Name:[Ignore, Bad.*]}'
|
21
|
+
# ./check-sensu-client.rb -w 20 -f "{name:tag-value,values:[infrastructure]}" -e '{Name:[Ignore, Bad.*]} {Sensu: [Ignore]}'
|
22
|
+
#
|
23
|
+
# NOTES:
|
24
|
+
# Values provided for the exclusion filter are treated as regex's for evaluation purposes. Any matching value
|
25
|
+
# will result in the instance being excluded
|
26
|
+
#
|
27
|
+
# LICENSE:
|
28
|
+
# Justin McCarty (jmccarty3@gmail.com)
|
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
|
+
require 'net/http'
|
37
|
+
require 'json'
|
38
|
+
|
39
|
+
class CheckSensuClient < Sensu::Plugin::Check::CLI
|
40
|
+
include Filter
|
41
|
+
include Common
|
42
|
+
option :aws_region,
|
43
|
+
short: '-r AWS_REGION',
|
44
|
+
long: '--aws-region REGION',
|
45
|
+
description: 'AWS Region (such as us-east-1).',
|
46
|
+
default: 'us-east-1'
|
47
|
+
|
48
|
+
option :sensu_host,
|
49
|
+
short: '-h SENSU_HOST',
|
50
|
+
long: '--host SENSU_HOST',
|
51
|
+
description: 'Sensu host to query',
|
52
|
+
default: 'sensu'
|
53
|
+
|
54
|
+
option :sensu_port,
|
55
|
+
short: '-p SENSU_PORT',
|
56
|
+
long: '--port SENSU_PORT',
|
57
|
+
description: 'Sensu API port',
|
58
|
+
proc: proc(&:to_i),
|
59
|
+
default: 4567
|
60
|
+
|
61
|
+
option :warn,
|
62
|
+
short: '-w WARN',
|
63
|
+
description: 'Warn if instance has been up longer (Minutes)',
|
64
|
+
proc: proc(&:to_i),
|
65
|
+
default: 0
|
66
|
+
|
67
|
+
option :critical,
|
68
|
+
short: '-c CRITICAL',
|
69
|
+
description: 'Critical if instance has been up longer (Minutes)',
|
70
|
+
proc: proc(&:to_i)
|
71
|
+
|
72
|
+
option :min,
|
73
|
+
short: '-m MIN_TIME',
|
74
|
+
description: 'Minimum Time an instance must be running (Minutes)',
|
75
|
+
proc: proc(&:to_i),
|
76
|
+
default: 5
|
77
|
+
|
78
|
+
option :filter,
|
79
|
+
short: '-f FILTER',
|
80
|
+
description: 'Filter to use to find ec2 instances',
|
81
|
+
default: '{}'
|
82
|
+
|
83
|
+
option :exclude_tags,
|
84
|
+
short: '-e {<tag-key>:[VAL1, VAL2]} {<tag-key>:[VAL1, VAL2] }',
|
85
|
+
long: '--exclude_tags {<tag-key>:[VAL1, VAL2] } {<tag-key>:[VAL1, VAL2] }',
|
86
|
+
description: 'Tag Values to exclude by. Values treated as regex. Any matching value will result in exclusion.',
|
87
|
+
default: '{}'
|
88
|
+
|
89
|
+
def run
|
90
|
+
# Converting the string into a hash.
|
91
|
+
filter_list = config[:exclude_tags].split(/}\s?{/).map do |x|
|
92
|
+
x.gsub(/[{}]/, '')
|
93
|
+
end
|
94
|
+
filter_list = filter_list.map do |y|
|
95
|
+
h1, h2 = y.split(':')
|
96
|
+
{ h1 => h2 }
|
97
|
+
end.reduce(:merge)
|
98
|
+
filter_list.delete(nil)
|
99
|
+
filter_list.each { |x, y| filter_list[x] = y.strip.gsub(/[\[\]]/, '') }
|
100
|
+
client = Aws::EC2::Client.new aws_config
|
101
|
+
|
102
|
+
parsed_filter = Filter.parse(config[:filter])
|
103
|
+
|
104
|
+
filter = if parsed_filter.empty?
|
105
|
+
{}
|
106
|
+
else
|
107
|
+
{ filters: parsed_filter }
|
108
|
+
end
|
109
|
+
|
110
|
+
data = client.describe_instances(filter)
|
111
|
+
|
112
|
+
current_time = Time.now.utc
|
113
|
+
aws_instances = Set.new
|
114
|
+
data.reservations.each do |r|
|
115
|
+
r.instances.each do |i|
|
116
|
+
aws_instances << {
|
117
|
+
id: i[:instance_id],
|
118
|
+
up_time: (current_time - i[:launch_time]) / 60,
|
119
|
+
tags: i.tags
|
120
|
+
}
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
sensu_clients = client_check
|
125
|
+
|
126
|
+
missing = Set.new
|
127
|
+
|
128
|
+
aws_instances.delete_if do |instance|
|
129
|
+
instance[:tags].any? do |key|
|
130
|
+
filter_list.keys.include?(key.key) && filter_list[key.key].split(',').any? do |v|
|
131
|
+
key.value.match(/#{v.strip}/)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
aws_instances.each do |i|
|
137
|
+
if sensu_clients.include?(i[:id]) == false
|
138
|
+
if i[:up_time] > config[:min]
|
139
|
+
missing << i
|
140
|
+
output "Missing instance #{i[:id]}. Uptime: #{i[:up_time]} Minutes"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
warn_flag = false
|
146
|
+
crit_flag = false
|
147
|
+
|
148
|
+
missing.each do |m|
|
149
|
+
if (config[:critical].nil? == false) && (m[:up_time] > config[:critical])
|
150
|
+
crit_flag = true
|
151
|
+
elsif (config[:warn].nil? == false) && (m[:up_time] > config[:warn])
|
152
|
+
warn_flag = true
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
if crit_flag
|
157
|
+
critical
|
158
|
+
elsif warn_flag
|
159
|
+
warning
|
160
|
+
end
|
161
|
+
ok
|
162
|
+
end
|
163
|
+
|
164
|
+
def client_check
|
165
|
+
uri = URI("http://#{config[:sensu_host]}:#{config[:sensu_port]}/clients")
|
166
|
+
response = JSON.parse(Net::HTTP.get(uri))
|
167
|
+
|
168
|
+
clients = Set.new
|
169
|
+
response.each do |client|
|
170
|
+
clients << client['name']
|
171
|
+
end
|
172
|
+
|
173
|
+
clients
|
174
|
+
end
|
175
|
+
end
|
data/bin/check-sqs-messages.rb
CHANGED
@@ -16,8 +16,8 @@
|
|
16
16
|
# gem: sensu-plugin
|
17
17
|
#
|
18
18
|
# USAGE:
|
19
|
-
#
|
20
|
-
#
|
19
|
+
# check-sqs-messages -q my_queue -a key -k secret -w 500 -c 1000
|
20
|
+
# check-sqs-messages -p queue_prefix_ -a key -k secret -W 100 -C 50
|
21
21
|
#
|
22
22
|
# NOTES:
|
23
23
|
#
|
@@ -56,7 +56,13 @@ class SQSMsgs < Sensu::Plugin::Check::CLI
|
|
56
56
|
short: '-q SQS_QUEUE',
|
57
57
|
long: '--queue SQS_QUEUE',
|
58
58
|
description: 'The name of the SQS you want to check the number of messages for',
|
59
|
-
|
59
|
+
default: ''
|
60
|
+
|
61
|
+
option :prefix,
|
62
|
+
short: '-p PREFIX',
|
63
|
+
long: '--prefix PREFIX',
|
64
|
+
description: 'The prefix of the queues you want to check the number of messages for',
|
65
|
+
default: ''
|
60
66
|
|
61
67
|
option :warn_over,
|
62
68
|
short: '-w WARN_OVER',
|
@@ -96,14 +102,46 @@ class SQSMsgs < Sensu::Plugin::Check::CLI
|
|
96
102
|
def run
|
97
103
|
AWS.config aws_config
|
98
104
|
sqs = AWS::SQS.new
|
99
|
-
messages = sqs.queues.named(config[:queue]).approximate_number_of_messages
|
100
105
|
|
101
|
-
if
|
102
|
-
|
103
|
-
|
104
|
-
|
106
|
+
if config[:prefix] == ''
|
107
|
+
if config[:queue] == ''
|
108
|
+
critical 'Error, either QUEUE or PREFIX must be specified'
|
109
|
+
end
|
110
|
+
|
111
|
+
messages = sqs.queues.named(config[:queue]).approximate_number_of_messages
|
112
|
+
|
113
|
+
if (config[:crit_under] >= 0 && messages < config[:crit_under]) || (config[:crit_over] >= 0 && messages > config[:crit_over])
|
114
|
+
critical "#{messages} message(s) in #{config[:queue]} queue"
|
115
|
+
elsif (config[:warn_under] >= 0 && messages < config[:warn_under]) || (config[:warn_over] >= 0 && messages > config[:warn_over])
|
116
|
+
warning "#{messages} message(s) in #{config[:queue]} queue"
|
117
|
+
else
|
118
|
+
ok "#{messages} messages in #{config[:queue]} queue"
|
119
|
+
end
|
105
120
|
else
|
106
|
-
|
121
|
+
warn = false
|
122
|
+
crit = false
|
123
|
+
queues = []
|
124
|
+
|
125
|
+
sqs.queues.with_prefix(config[:prefix]).each do |q|
|
126
|
+
queue_name = q.arn.split(':').last
|
127
|
+
messages = q.approximate_number_of_messages
|
128
|
+
|
129
|
+
if (config[:crit_under] >= 0 && messages < config[:crit_under]) || (config[:crit_over] >= 0 && messages > config[:crit_over])
|
130
|
+
crit = true
|
131
|
+
queues << "#{messages} message(s) in #{queue_name} queue"
|
132
|
+
elsif (config[:warn_under] >= 0 && messages < config[:warn_under]) || (config[:warn_over] >= 0 && messages > config[:warn_over])
|
133
|
+
warn = true
|
134
|
+
queues << "#{messages} message(s) in #{queue_name} queue"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
if crit
|
139
|
+
critical queues.to_s
|
140
|
+
elsif warn
|
141
|
+
warning queues.to_s
|
142
|
+
else
|
143
|
+
ok "All queues matching prefix '#{config[:prefix]}' OK"
|
144
|
+
end
|
107
145
|
end
|
108
146
|
end
|
109
147
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-trustedadvisor-service-limits
|
4
|
+
#
|
5
|
+
#
|
6
|
+
# DESCRIPTION:
|
7
|
+
# This plugin uses Trusted Advisor API to perform check for
|
8
|
+
# service limits. Trigger 'critical' on sensu for services
|
9
|
+
# that are not 'Green'.
|
10
|
+
#
|
11
|
+
# IAM requires AWSSupportAccess policy enabled.
|
12
|
+
#
|
13
|
+
# https://aws.amazon.com/premiumsupport/ta-faqs/
|
14
|
+
#
|
15
|
+
#
|
16
|
+
# OUTPUT:
|
17
|
+
# plain-text
|
18
|
+
#
|
19
|
+
# PLATFORMS:
|
20
|
+
# Linux
|
21
|
+
#
|
22
|
+
# DEPENDENCIES:
|
23
|
+
# gem: aws-sdk-v1
|
24
|
+
# gem: sensu-plugin
|
25
|
+
#
|
26
|
+
# USAGE:
|
27
|
+
# ./check-trustedadvisor-service-limits.rb -l {en|ja}
|
28
|
+
#
|
29
|
+
# NOTES:
|
30
|
+
#
|
31
|
+
# LICENSE:
|
32
|
+
# Seandy Wibowo <swibowo@sugarcrm.com>
|
33
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
34
|
+
# for details.
|
35
|
+
|
36
|
+
require 'sensu-plugin/check/cli'
|
37
|
+
require 'sensu-plugins-aws'
|
38
|
+
require 'aws-sdk'
|
39
|
+
|
40
|
+
class CheckTrustedAdvisorServiceLimits < Sensu::Plugin::Check::CLI
|
41
|
+
include Common
|
42
|
+
option :aws_language,
|
43
|
+
short: '-l AWS_LANGUAGE',
|
44
|
+
long: '--aws-language AWS_LANGUAGE',
|
45
|
+
description: "ISO 639-1 language code to be used when querying Trusted Advisor API. Only 'en' and 'ja' supported for now",
|
46
|
+
default: 'en'
|
47
|
+
|
48
|
+
def run
|
49
|
+
# The Support endpoint seems to only available in us-east-1 region
|
50
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/Support.html
|
51
|
+
aws_support = Aws::Support::Client.new(region: 'us-east-1')
|
52
|
+
|
53
|
+
service_limit_msg = []
|
54
|
+
|
55
|
+
begin
|
56
|
+
# service limit check
|
57
|
+
# Perform a refresh to make sure the API result is not stale.
|
58
|
+
aws_support.refresh_trusted_advisor_check(check_id: 'eW7HH0l7J9')
|
59
|
+
sl = aws_support.describe_trusted_advisor_check_result(check_id: 'eW7HH0l7J9', language: config[:aws_language])
|
60
|
+
|
61
|
+
sl[:result][:flagged_resources].each do |slr|
|
62
|
+
# Data structure will be as follow
|
63
|
+
# ["<region>", "<service>", "<description>", "<limit>", "<usage>", "<status>"]
|
64
|
+
sl_region, sl_service, sl_description, sl_limit, sl_usage, sl_status = slr[:metadata]
|
65
|
+
|
66
|
+
next if sl_status == 'Green'
|
67
|
+
sl_usage = 0 if sl_usage.nil?
|
68
|
+
|
69
|
+
sl_msg = "#{sl_service} (#{sl_region}) #{sl_description} #{sl_usage} out of #{sl_limit}"
|
70
|
+
service_limit_msg.push(sl_msg)
|
71
|
+
end
|
72
|
+
rescue => e
|
73
|
+
unknown "An error occurred processing AWS TrustedAdvisor API: #{e.message}"
|
74
|
+
end
|
75
|
+
|
76
|
+
if service_limit_msg.empty?
|
77
|
+
ok
|
78
|
+
else
|
79
|
+
critical("Services hitting usage limit: #{service_limit_msg.join(', ')}")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/bin/metrics-elasticache.rb
CHANGED
@@ -98,6 +98,21 @@ class ElastiCacheMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
98
98
|
config[:scheme]
|
99
99
|
end
|
100
100
|
|
101
|
+
dimensions = if config[:cachenodeid]
|
102
|
+
[{
|
103
|
+
'name' => 'CacheClusterId',
|
104
|
+
'value' => config[:cacheclusterid]
|
105
|
+
}, {
|
106
|
+
'name' => 'CacheNodeId',
|
107
|
+
'value' => config[:cachenodeid]
|
108
|
+
}]
|
109
|
+
else
|
110
|
+
[{
|
111
|
+
'name' => 'CacheClusterId',
|
112
|
+
'value' => config[:cacheclusterid]
|
113
|
+
}]
|
114
|
+
end
|
115
|
+
|
101
116
|
statistic_type = {
|
102
117
|
'redis' => {
|
103
118
|
'CPUUtilization' => 'Percent',
|
@@ -168,9 +183,7 @@ class ElastiCacheMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
168
183
|
options = {
|
169
184
|
'namespace' => 'AWS/ElastiCache',
|
170
185
|
'metric_name' => config[:metric],
|
171
|
-
'dimensions' =>
|
172
|
-
{ 'name' => 'CacheClusterId', 'value' => config[:cacheclusterid] }
|
173
|
-
],
|
186
|
+
'dimensions' => dimensions,
|
174
187
|
'start_time' => st.iso8601,
|
175
188
|
'end_time' => et.iso8601,
|
176
189
|
'period' => 60,
|
data/bin/metrics-sqs.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# sqs
|
3
|
+
# metrics-sqs
|
4
4
|
#
|
5
5
|
# DESCRIPTION:
|
6
6
|
# Fetch SQS metrics
|
@@ -16,7 +16,8 @@
|
|
16
16
|
# gem: sensu-plugin
|
17
17
|
#
|
18
18
|
# USAGE:
|
19
|
-
# sqs
|
19
|
+
# metrics-sqs -q my_queue -a key -k secret
|
20
|
+
# metrics-sqs -p queue_prefix_ -a key -k secret
|
20
21
|
#
|
21
22
|
# NOTES:
|
22
23
|
#
|
@@ -34,7 +35,13 @@ class SQSMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
34
35
|
description: 'Name of the queue',
|
35
36
|
short: '-q QUEUE',
|
36
37
|
long: '--queue QUEUE',
|
37
|
-
|
38
|
+
default: ''
|
39
|
+
|
40
|
+
option :prefix,
|
41
|
+
description: 'Queue name prefix',
|
42
|
+
short: '-p PREFIX',
|
43
|
+
long: '--prefix PREFIX',
|
44
|
+
default: ''
|
38
45
|
|
39
46
|
option :scheme,
|
40
47
|
description: 'Metric naming scheme, text to prepend to metric',
|
@@ -67,19 +74,33 @@ class SQSMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
67
74
|
}
|
68
75
|
end
|
69
76
|
|
70
|
-
def
|
71
|
-
|
72
|
-
|
73
|
-
else
|
74
|
-
config[:scheme]
|
75
|
-
end
|
77
|
+
def scheme(queue_name)
|
78
|
+
"aws.sqs.queue.#{queue_name.tr('-', '_')}.message_count"
|
79
|
+
end
|
76
80
|
|
81
|
+
def run
|
77
82
|
begin
|
78
83
|
sqs = AWS::SQS.new aws_config
|
79
84
|
|
80
|
-
|
81
|
-
|
85
|
+
if config[:prefix] == ''
|
86
|
+
if config[:queue] == ''
|
87
|
+
critical 'Error, either QUEUE or PREFIX must be specified'
|
88
|
+
end
|
89
|
+
|
90
|
+
scheme = if config[:scheme] == ''
|
91
|
+
scheme config[:queue]
|
92
|
+
else
|
93
|
+
config[:scheme]
|
94
|
+
end
|
82
95
|
|
96
|
+
messages = sqs.queues.named(config[:queue]).approximate_number_of_messages
|
97
|
+
output scheme, messages
|
98
|
+
else
|
99
|
+
sqs.queues.with_prefix(config[:prefix]).each do |q|
|
100
|
+
queue_name = q.arn.split(':').last
|
101
|
+
output scheme(queue_name), q.approximate_number_of_messages
|
102
|
+
end
|
103
|
+
end
|
83
104
|
rescue => e
|
84
105
|
critical "Error fetching SQS queue metrics: #{e.message}"
|
85
106
|
end
|
metadata
CHANGED
@@ -1,45 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURuakNDQW9hZ0F3SUJB
|
13
|
-
Z0lCQVRBTkJna3Foa2lHOXcwQkFRVUZBREJLTVJVd0V3WURWUVFEREF4elpX
|
14
|
-
NXoKZFMxd2JIVm5hVzR4SFRBYkJnb0praWFKay9Jc1pBRVpGZzF6Wlc1emRT
|
15
|
-
MXdiSFZuYVc1ek1SSXdFQVlLQ1pJbQppWlB5TEdRQkdSWUNhVzh3SGhjTk1U
|
16
|
-
WXdNakEwTWpNeU1qRTNXaGNOTVRjd01qQXpNak15TWpFM1dqQktNUlV3CkV3
|
17
|
-
WURWUVFEREF4elpXNXpkUzF3YkhWbmFXNHhIVEFiQmdvSmtpYUprL0lzWkFF
|
18
|
-
WkZnMXpaVzV6ZFMxd2JIVm4KYVc1ek1SSXdFQVlLQ1pJbWlaUHlMR1FCR1JZ
|
19
|
-
Q2FXOHdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCRHdBdwpnZ0VLQW9J
|
20
|
-
QkFRQy9VUzNmdEkyUmQrOWQzS3JIQUw0bERsOGxhN2s2ZHA3K1RPY210VHd3
|
21
|
-
YzRiMUwzV0NyeEFoClpDWms1Q3k2aUpvWUd4VHVoNittSDJZZ3ExbHZGRE4v
|
22
|
-
NTh5YVRHTVFINzNRYVJjZjVnak9IMkJSQTlkUWRzWUgKYTNZYnMrbGxwVlYv
|
23
|
-
ZC9kMklaYyt2RU9tc21rTFpVeEhzZFdQSTZsWTBuYXJwU2RxNHNML0lXWWZP
|
24
|
-
aW1ocFFTWgpTV0t5WHg5cjM4UFpZZ0Q3djIydjloNTZkcUpQZFFPY29OODhF
|
25
|
-
NkE4YTdQWTcvL1RweWdTREtuSldudkFwS1JxCjNCN0xMaFNkOTRQMHdRcGow
|
26
|
-
MS9sb05Nd0FCMytGQjRRQ0UrdG1QeFYxZ1Q2ZWE4VW1SNjQrcGZKTFN0NGl5
|
27
|
-
N0gKVGc5OTdCZFZqaURJdG5SYzhCSXNjVFl4S2JRai9wTEhBZ01CQUFHamdZ
|
28
|
-
NHdnWXN3Q1FZRFZSMFRCQUl3QURBTApCZ05WSFE4RUJBTUNCTEF3SFFZRFZS
|
29
|
-
ME9CQllFRk5McjBmZ1BmdnlWK0VneEVGRHhVcVFhU2xScE1DZ0dBMVVkCkVR
|
30
|
-
UWhNQitCSFhObGJuTjFMWEJzZFdkcGJrQnpaVzV6ZFMxd2JIVm5hVzV6TG1s
|
31
|
-
dk1DZ0dBMVVkRWdRaE1CK0IKSFhObGJuTjFMWEJzZFdkcGJrQnpaVzV6ZFMx
|
32
|
-
d2JIVm5hVzV6TG1sdk1BMEdDU3FHU0liM0RRRUJCUVVBQTRJQgpBUUNQZTZ0
|
33
|
-
RUJ0NS9uQzk1aFhvS2VLRmhrWVc5bTE2aU5YdWRKeEorZGRYcnpDc2tEMXk2
|
34
|
-
ajZjQXY0a1FlUDFmClBIbDE4aDVrOWtKeElQU1IrcUkrK2JJbDE3ZUVPU096
|
35
|
-
YXNMbXdzdGFNU25NN3U1UWZMcFdFWTJldVZXQkRzdGQKMmhrcG80VSswSzVT
|
36
|
-
d3ptZEphMFdLQXRmS3ZkdENROGk5MllJUCtIODNFdXZDU0xwZ29aaDYzRXJx
|
37
|
-
dVFVY25lbgphZmg1bHVUQkExaTFjcUJHNEFNSjBmTFdHeU9xSmFYOFA5WnN4
|
38
|
-
RERXUEVCbk5TaVd2WGIrSUttSkFWTzF1VzRrClFOODNielZXU1d1bFk4Qlk2
|
39
|
-
a1grSVFNd1lhelpBbEIvMTNkN2E4VTBoN0NyYjM2Sm5TUGF0aHVSemU0cUtY
|
40
|
-
RlEKM2YzVFVaV3d2UmZ0Y1N1K3Z0Y0JSa00wCi0tLS0tRU5EIENFUlRJRklD
|
41
|
-
QVRFLS0tLS0K
|
42
|
-
date: 2016-02-07 00:00:00.000000000 Z
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
43
12
|
dependencies:
|
44
13
|
- !ruby/object:Gem::Dependency
|
45
14
|
name: aws-sdk
|
@@ -270,6 +239,7 @@ executables:
|
|
270
239
|
- check-ec2-filter.rb
|
271
240
|
- check-ec2-network.rb
|
272
241
|
- check-eip-allocation.rb
|
242
|
+
- check-elasticache-failover.rb
|
273
243
|
- check-elb-certs.rb
|
274
244
|
- check-elb-health-fog.rb
|
275
245
|
- check-elb-health-sdk.rb
|
@@ -285,11 +255,12 @@ executables:
|
|
285
255
|
- check-redshift-events.rb
|
286
256
|
- check-s3-bucket.rb
|
287
257
|
- check-s3-object.rb
|
258
|
+
- check-sensu-client.rb
|
288
259
|
- check-ses-limit.rb
|
289
260
|
- check-sqs-messages.rb
|
261
|
+
- check-trustedadvisor-service-limits.rb
|
290
262
|
- check-vpc-nameservers.rb
|
291
263
|
- check-vpc-vpn.rb
|
292
|
-
- check_vpc_vpn.py
|
293
264
|
- handler-ec2_node.rb
|
294
265
|
- handler-ses.rb
|
295
266
|
- handler-sns.rb
|
@@ -318,6 +289,7 @@ files:
|
|
318
289
|
- bin/check-ec2-filter.rb
|
319
290
|
- bin/check-ec2-network.rb
|
320
291
|
- bin/check-eip-allocation.rb
|
292
|
+
- bin/check-elasticache-failover.rb
|
321
293
|
- bin/check-elb-certs.rb
|
322
294
|
- bin/check-elb-health-fog.rb
|
323
295
|
- bin/check-elb-health-sdk.rb
|
@@ -333,8 +305,10 @@ files:
|
|
333
305
|
- bin/check-redshift-events.rb
|
334
306
|
- bin/check-s3-bucket.rb
|
335
307
|
- bin/check-s3-object.rb
|
308
|
+
- bin/check-sensu-client.rb
|
336
309
|
- bin/check-ses-limit.rb
|
337
310
|
- bin/check-sqs-messages.rb
|
311
|
+
- bin/check-trustedadvisor-service-limits.rb
|
338
312
|
- bin/check-vpc-nameservers.rb
|
339
313
|
- bin/check-vpc-vpn.rb
|
340
314
|
- bin/check_vpc_vpn.py
|
checksums.yaml.gz.sig
DELETED
Binary file
|
data.tar.gz.sig
DELETED
Binary file
|
metadata.gz.sig
DELETED
Binary file
|