sensu-plugins-aws 0.0.3 → 0.0.4
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 +4 -0
- data/README.md +1 -1
- data/bin/check-ebs-snapshots.rb +94 -0
- data/lib/sensu-plugins-aws.rb +1 -0
- data/lib/sensu-plugins-aws/common.rb +34 -0
- data/lib/sensu-plugins-aws/version.rb +1 -1
- metadata +19 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cece8a458614d75cb1de7e06e9ae6621f36d5b7
|
4
|
+
data.tar.gz: a2f8aa1261f5129b66b91ba8a78baccb59ee6595
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c3ea581f55a1e0f2576a1f02dc7516ca01eaf43f41b0641a9a12a2ad4d90b72d6fb0900ba96c02e9cc07014113956f54ffd9197d6ddf85459196f83bccdbaf4
|
7
|
+
data.tar.gz: f88cfd661753410f3b42efb94cc82818d281ab8fdf65d05d4b0b88e986ddeec65b733a291c7a183005b3c7c88b88cae5dfbb2cd492cb58ea8a37d677c5eea914
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,10 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## Unreleased][unreleased]
|
7
7
|
|
8
|
+
## [0.0.4] - 2015-07-05
|
9
|
+
### Added
|
10
|
+
- Added the ability to alert on un-snapshotted ebs volumes
|
11
|
+
|
8
12
|
## [0.0.3] - 2015-06-26
|
9
13
|
### Fixed
|
10
14
|
- Access key and secret key should be optional
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-aws/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-aws)
|
6
6
|
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-aws/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-aws)
|
7
7
|
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-aws.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-aws)
|
8
|
-
[
|
8
|
+
[![Codeship Status for sensu-plugins/sensu-plugins-aws](https://codeship.com/projects/2a9c6e70-d4b4-0132-67ee-4e043b6b23b5/status?branch=master)](https://codeship.com/projects/77866)
|
9
9
|
|
10
10
|
## Functionality
|
11
11
|
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-ebs-snapshots
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Check EC2 Attached Volumes for Snapshots. Only for Volumes with a Name tag.
|
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-ebs-snapshots.rb -r ${you_region}
|
20
|
+
# ./check-ebs-snapshots.rb -r ${you_region} -p 1
|
21
|
+
#
|
22
|
+
# NOTES:
|
23
|
+
#
|
24
|
+
# LICENSE:
|
25
|
+
# Shane Starcher <shane.starcher@gmail.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 'sensu-plugins-aws'
|
32
|
+
require 'aws-sdk'
|
33
|
+
|
34
|
+
class CheckEbsSnapshots < Sensu::Plugin::Check::CLI
|
35
|
+
include Common
|
36
|
+
option :period,
|
37
|
+
short: '-p N',
|
38
|
+
long: '--period Days',
|
39
|
+
default: 7,
|
40
|
+
description: 'Length in time to alert on missing snapshots'
|
41
|
+
|
42
|
+
option :aws_region,
|
43
|
+
short: '-r R',
|
44
|
+
long: '--region REGION',
|
45
|
+
description: 'AWS region',
|
46
|
+
default: 'us-east-1'
|
47
|
+
|
48
|
+
def run
|
49
|
+
errors = []
|
50
|
+
ec2 = Aws::EC2::Client.new
|
51
|
+
|
52
|
+
volumes = ec2.describe_volumes(
|
53
|
+
filters: [
|
54
|
+
{
|
55
|
+
name: 'attachment.status',
|
56
|
+
values: ['attached']
|
57
|
+
},
|
58
|
+
{
|
59
|
+
name: 'tag-key',
|
60
|
+
values: ['Name']
|
61
|
+
}
|
62
|
+
]
|
63
|
+
)
|
64
|
+
|
65
|
+
volumes[:volumes].each do |volume|
|
66
|
+
tags = volume[:tags].map { |a| Hash[*a] }.reduce(:merge) || {}
|
67
|
+
|
68
|
+
snapshots = ec2.describe_snapshots(
|
69
|
+
filters: [
|
70
|
+
{
|
71
|
+
name: 'volume-id',
|
72
|
+
values: [volume[:volume_id]]
|
73
|
+
}
|
74
|
+
]
|
75
|
+
)
|
76
|
+
|
77
|
+
sorted_times = snapshots[:snapshots].sort_by { |i| i[:start_time].to_i }
|
78
|
+
if !sorted_times.empty?
|
79
|
+
latest_snapshot = sorted_times[-1][:start_time]
|
80
|
+
if (Date.today - config[:period].to_i).to_time > latest_snapshot
|
81
|
+
errors << "#{tags['Name']} latest snapshot is #{latest_snapshot} for #{volume[:volume_id]}"
|
82
|
+
end
|
83
|
+
else
|
84
|
+
errors << " #{tags['Name']} has no snapshots for #{volume[:volume_id]}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
if errors.empty?
|
89
|
+
ok
|
90
|
+
else
|
91
|
+
warning errors.join("\n")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/sensu-plugins-aws.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
#
|
2
|
+
# DESCRIPTION:
|
3
|
+
# Common helper methods
|
4
|
+
#
|
5
|
+
# DEPENDENCIES:
|
6
|
+
# gem: aws-sdk
|
7
|
+
# gem: sensu-plugin
|
8
|
+
#
|
9
|
+
# USAGE:
|
10
|
+
#
|
11
|
+
# NOTES:
|
12
|
+
#
|
13
|
+
# LICENSE:
|
14
|
+
# Shane Starcher <shane.starcher@gmail.com>
|
15
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
16
|
+
# for details.
|
17
|
+
#
|
18
|
+
|
19
|
+
module Common
|
20
|
+
def initialize
|
21
|
+
super()
|
22
|
+
aws_config
|
23
|
+
end
|
24
|
+
|
25
|
+
def aws_config
|
26
|
+
Aws.config.update(
|
27
|
+
credentials: Aws::Credentials.new(config[:aws_access_key], config[:aws_secret_access_key])
|
28
|
+
) if config[:aws_access_key] && config[:aws_secret_access_key]
|
29
|
+
|
30
|
+
Aws.config.update(
|
31
|
+
region: config[:aws_region]
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
31
|
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2015-
|
33
|
+
date: 2015-07-07 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: sensu-plugin
|
@@ -46,6 +46,20 @@ dependencies:
|
|
46
46
|
- - '='
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 1.1.0
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: aws-sdk
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.0.48
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.0.48
|
49
63
|
- !ruby/object:Gem::Dependency
|
50
64
|
name: aws-sdk-v1
|
51
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -240,6 +254,7 @@ executables:
|
|
240
254
|
- check-elb-health-fog.rb
|
241
255
|
- check-elb-certs.rb
|
242
256
|
- check-ec2-network.rb
|
257
|
+
- check-ebs-snapshots.rb
|
243
258
|
- check-dynamodb-throttle.rb
|
244
259
|
- check-dynamodb-capacity.rb
|
245
260
|
- autoscaling-instance-count-metrics.rb
|
@@ -252,6 +267,7 @@ files:
|
|
252
267
|
- bin/autoscaling-instance-count-metrics.rb
|
253
268
|
- bin/check-dynamodb-capacity.rb
|
254
269
|
- bin/check-dynamodb-throttle.rb
|
270
|
+
- bin/check-ebs-snapshots.rb
|
255
271
|
- bin/check-ec2-network.rb
|
256
272
|
- bin/check-elb-certs.rb
|
257
273
|
- bin/check-elb-health-fog.rb
|
@@ -276,6 +292,7 @@ files:
|
|
276
292
|
- bin/metrics-elb.rb
|
277
293
|
- bin/metrics-sqs.rb
|
278
294
|
- lib/sensu-plugins-aws.rb
|
295
|
+
- lib/sensu-plugins-aws/common.rb
|
279
296
|
- lib/sensu-plugins-aws/version.rb
|
280
297
|
homepage: https://github.com/sensu-plugins/sensu-plugins-aws
|
281
298
|
licenses:
|
metadata.gz.sig
CHANGED
Binary file
|