zabbix-cloudwatch 0.0.5 → 0.0.6
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 +5 -5
- data/Gemfile.lock +11 -1
- data/README.md +34 -8
- data/bin/zabbix-cloudwatch +2 -2
- data/lib/zabbix-cloudwatch/version.rb +1 -1
- data/lib/zabbix-cloudwatch.rb +4 -5
- data/spec/spec_helper.rb +2 -0
- data/spec/zabbix-cloudwatch/zabbix-cloudwatch_spec.rb +166 -0
- data/zabbix-cloudwatch.gemspec +1 -0
- metadata +17 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
SHA1:
|
|
3
|
-
metadata.gz: df87bd47ab6fdee6de4d821369699e3f6d07aea0
|
|
4
|
-
data.tar.gz: 6dfa76015b98cd65c7bd09b4e1fc388fc0b295bc
|
|
5
2
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 668006ca05ddcdb72c2be727e55fd9ca3f02436b55ad05d79188bceb689d8c6abd612ab8eed200a40d1485ae191ac505be1293ff3747b494f17573d4aeba9738
|
|
4
|
+
data.tar.gz: 50b14743250d4aa4fa48a9b217039225e29157daa2024da499f6ef29a13f80c8ed1ae68b78757bace3977e22d4d3c1bb9e53246f585c377e4b38591c7a98f724
|
|
5
|
+
SHA1:
|
|
6
|
+
metadata.gz: 53a2da88f161acb42a0b710ba66e2fc2ecadb86c
|
|
7
|
+
data.tar.gz: 7d8cc21d6177256adf7e29f002f1c73f7a88b3ed
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
zabbix-cloudwatch (0.0.
|
|
4
|
+
zabbix-cloudwatch (0.0.5)
|
|
5
5
|
aws-sdk (~> 1.21.0)
|
|
6
6
|
getopt (~> 1.4.1)
|
|
7
7
|
|
|
@@ -12,13 +12,23 @@ GEM
|
|
|
12
12
|
json (~> 1.4)
|
|
13
13
|
nokogiri (>= 1.4.4, < 1.6.0)
|
|
14
14
|
uuidtools (~> 2.1)
|
|
15
|
+
diff-lcs (1.2.4)
|
|
15
16
|
getopt (1.4.1)
|
|
16
17
|
json (1.8.0)
|
|
17
18
|
nokogiri (1.5.10)
|
|
19
|
+
rspec (2.14.1)
|
|
20
|
+
rspec-core (~> 2.14.0)
|
|
21
|
+
rspec-expectations (~> 2.14.0)
|
|
22
|
+
rspec-mocks (~> 2.14.0)
|
|
23
|
+
rspec-core (2.14.5)
|
|
24
|
+
rspec-expectations (2.14.3)
|
|
25
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
26
|
+
rspec-mocks (2.14.3)
|
|
18
27
|
uuidtools (2.1.4)
|
|
19
28
|
|
|
20
29
|
PLATFORMS
|
|
21
30
|
ruby
|
|
22
31
|
|
|
23
32
|
DEPENDENCIES
|
|
33
|
+
rspec
|
|
24
34
|
zabbix-cloudwatch!
|
data/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# zabbix-cloudwatch
|
|
2
2
|
|
|
3
|
+
[](http://badge.fury.io/rb/zabbix-cloudwatch)
|
|
3
4
|
|
|
4
5
|
An external script for getting cloudwatch metrics into Zabbix
|
|
5
6
|
|
|
@@ -15,7 +16,7 @@ Usage: zabbix-cloudwatch
|
|
|
15
16
|
-s, --statistic Minimum|Maximum|Average|Sum|SampleCount Default: Average
|
|
16
17
|
--aws-access-key AWS Access Key
|
|
17
18
|
--aws-secret-key AWS Secret Key
|
|
18
|
-
--aws-region AWS Region
|
|
19
|
+
--aws-region AWS Region Default: us-east-1
|
|
19
20
|
```
|
|
20
21
|
|
|
21
22
|
## Getting it running
|
|
@@ -24,15 +25,15 @@ Usage: zabbix-cloudwatch
|
|
|
24
25
|
* for some of the gem dependencies, you will need the ruby development packages, gcc, libxml2, and libxslt
|
|
25
26
|
|
|
26
27
|
Modify these steps to taste (examples given running on the Amazon AMI 2013.03):
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
```bash
|
|
29
|
+
yum install ruby ruby-devel rubygems gcc libxml2-devel libxslt-devel
|
|
30
|
+
gem install bundler zabbix-cloudwatch
|
|
31
|
+
ln -s $(which zabbix-cloudwatch) /var/lib/zabbixsrv/externalscripts/zabbix-cloudwatch
|
|
31
32
|
```
|
|
32
33
|
|
|
33
34
|
## Examples
|
|
34
35
|
|
|
35
|
-
```
|
|
36
|
+
```bash
|
|
36
37
|
zabbix-cloudwatch -n AWS/EC2 \
|
|
37
38
|
-m CPUUtilization \
|
|
38
39
|
-d AutoScalingGroupName \
|
|
@@ -58,7 +59,7 @@ There are (3) ways to get your AWS Credentials into `zabbix-cloudwatch`.
|
|
|
58
59
|
permissions.**
|
|
59
60
|
|
|
60
61
|
### 1. Environment Variables (which is difficult with Zabbix):
|
|
61
|
-
```
|
|
62
|
+
```bash
|
|
62
63
|
export AWS_ACCESS_KEY_ID="YOUR ACCESS KEY"
|
|
63
64
|
export AWS_SECRET_ACCESS_KEY="YOUR SECRET ACCESS KEY"
|
|
64
65
|
export AWS_REGION="YOUR AWS REGION"
|
|
@@ -66,13 +67,38 @@ export AWS_REGION="YOUR AWS REGION"
|
|
|
66
67
|
|
|
67
68
|
### 2. Within the binary in the gem.
|
|
68
69
|
|
|
69
|
-
|
|
70
|
+
If you intend to do it this way, I suggest you make a copy of the binary
|
|
70
71
|
and place it in your zabbix externalscript path (instead of the suggested symlink in the installation example).
|
|
71
72
|
|
|
73
|
+
Find the binary like this:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
ls $(gem env gemdir)/gems/zabbix-cloudwatch-$(zabbix-cloudwatch --version)/bin/zabbix-cloudwatch
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
And place it in your externalscripts path like this (your zabbix path/user/group may be different):
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
cp $(gem env gemdir)/gems/zabbix-cloudwatch-$(zabbix-cloudwatch --version)/bin/zabbix-cloudwatch \
|
|
83
|
+
/var/lib/zabbixsrv/externalscripts/
|
|
84
|
+
chown zabbix:zabbix /var/lib/zabbixsrv/externalscripts/zabbix-cloudwatch
|
|
85
|
+
```
|
|
86
|
+
|
|
72
87
|
The class variables for this are at the very top of the file for your convenience.
|
|
73
88
|
|
|
74
89
|
### 3. Passing in your AWS Keys when you run zabbix-cloudwatch using the command line flags.
|
|
75
90
|
|
|
91
|
+
```bash
|
|
92
|
+
zabbix-cloudwatch -n AWS/AutoScaling \
|
|
93
|
+
-m GroupInServiceInstances \
|
|
94
|
+
-d AutoScalingGroupName \
|
|
95
|
+
-v your-auto-scaling-group \
|
|
96
|
+
--aws-access-key 'YOUR ACCESS KEY' \
|
|
97
|
+
--aws-secret-key 'YOUR SECRET KEY' \
|
|
98
|
+
--aws-region 'YOUR AWS REGION'
|
|
99
|
+
```
|
|
100
|
+
## Order of preference
|
|
101
|
+
|
|
76
102
|
The order of preference that this gem uses for the region and keys (individually) are:
|
|
77
103
|
|
|
78
104
|
* Commandline flag
|
data/bin/zabbix-cloudwatch
CHANGED
|
@@ -46,7 +46,7 @@ Usage: #{$0}
|
|
|
46
46
|
-s, --statistic Minimum|Maximum|Average|Sum|SampleCount Default: Average
|
|
47
47
|
--aws-access-key AWS Access Key
|
|
48
48
|
--aws-secret-key AWS Secret Key
|
|
49
|
-
--aws-region AWS Region
|
|
49
|
+
--aws-region AWS Region Default: us-east-1
|
|
50
50
|
|
|
51
51
|
EOF
|
|
52
52
|
exit 1
|
|
@@ -69,7 +69,7 @@ unless opts.key?"aws-secret-key"
|
|
|
69
69
|
opts["aws-secret-key"] = (@@aws_secret_key == '' && ENV["AWS_SECRET_ACCESS_KEY"]) || @@aws_secret_key
|
|
70
70
|
end
|
|
71
71
|
unless opts.key?"aws-region"
|
|
72
|
-
opts["aws-region"] =
|
|
72
|
+
opts["aws-region"] = (@@aws_region == '' && ENV["AWS_REGION"]) || @@aws_region
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
inst = ZabbixCloudwatch::GetCloudwatchMetric.new(opts)
|
data/lib/zabbix-cloudwatch.rb
CHANGED
|
@@ -14,7 +14,7 @@ module ZabbixCloudwatch
|
|
|
14
14
|
|
|
15
15
|
attr_accessor :options, :aws, :start_time, :end_time, :period, :statistic
|
|
16
16
|
|
|
17
|
-
def initialize options
|
|
17
|
+
def initialize options = {}
|
|
18
18
|
self.options = options
|
|
19
19
|
usage if options.key?"help"
|
|
20
20
|
raise NamespaceArgumentMissingException unless options.key?"namespace"
|
|
@@ -22,9 +22,6 @@ module ZabbixCloudwatch
|
|
|
22
22
|
raise DimensionArgumentMissingException unless options.key?"dimension-name"
|
|
23
23
|
raise DimensionArgumentMissingException unless options.key?"dimension-value"
|
|
24
24
|
self.aws = AWS::CloudWatch.new(get_aws_options).client
|
|
25
|
-
test_aws_connectivity
|
|
26
|
-
set_time_range
|
|
27
|
-
set_statistic
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def get_aws_options
|
|
@@ -35,7 +32,6 @@ module ZabbixCloudwatch
|
|
|
35
32
|
else
|
|
36
33
|
region = 'us-east-1'
|
|
37
34
|
end
|
|
38
|
-
puts options.inspect
|
|
39
35
|
{:access_key_id => options["aws-access-key"], :secret_access_key => options["aws-secret-key"], :region => region}
|
|
40
36
|
end
|
|
41
37
|
|
|
@@ -87,6 +83,9 @@ module ZabbixCloudwatch
|
|
|
87
83
|
end
|
|
88
84
|
|
|
89
85
|
def run!
|
|
86
|
+
test_aws_connectivity
|
|
87
|
+
set_time_range
|
|
88
|
+
set_statistic
|
|
90
89
|
ret = aws.get_metric_statistics({
|
|
91
90
|
:namespace => options["namespace"],
|
|
92
91
|
:metric_name => options["metricname"],
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'date'
|
|
3
|
+
|
|
4
|
+
def capture_stdout(&block)
|
|
5
|
+
original_stdout = $stdout
|
|
6
|
+
$stdout = fake = StringIO.new
|
|
7
|
+
begin
|
|
8
|
+
yield
|
|
9
|
+
ensure
|
|
10
|
+
$stdout = original_stdout
|
|
11
|
+
end
|
|
12
|
+
fake.string
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
module ZabbixCloudwatch
|
|
16
|
+
describe GetCloudwatchMetric do
|
|
17
|
+
describe "#new" do
|
|
18
|
+
it "Raises NamespaceArgumentMissingException when options are empty" do
|
|
19
|
+
lambda {ZabbixCloudwatch::GetCloudwatchMetric.new}.should raise_error GetCloudwatchMetric::NamespaceArgumentMissingException
|
|
20
|
+
end
|
|
21
|
+
it "Raises NamespaceArgumentMissingException when there is no namespace key in the options" do
|
|
22
|
+
options = {}
|
|
23
|
+
lambda {ZabbixCloudwatch::GetCloudwatchMetric.new(options)}.should raise_error GetCloudwatchMetric::NamespaceArgumentMissingException
|
|
24
|
+
end
|
|
25
|
+
it "Raises MetricnameArgumentMissingException when there is no metricname key in the options" do
|
|
26
|
+
options = {"namespace" => ''}
|
|
27
|
+
lambda {ZabbixCloudwatch::GetCloudwatchMetric.new(options)}.should raise_error GetCloudwatchMetric::MetricnameArgumentMissingException
|
|
28
|
+
end
|
|
29
|
+
it "Raises DimensionArgumentMissingException when both dimension keys are not in the options" do
|
|
30
|
+
options = {"namespace" => '', "metricname" => ''}
|
|
31
|
+
lambda {ZabbixCloudwatch::GetCloudwatchMetric.new(options)}.should raise_error GetCloudwatchMetric::DimensionArgumentMissingException
|
|
32
|
+
options = {"namespace" => '', "metricname" => '', "dimension-name" => ''}
|
|
33
|
+
lambda {ZabbixCloudwatch::GetCloudwatchMetric.new(options)}.should raise_error GetCloudwatchMetric::DimensionArgumentMissingException
|
|
34
|
+
options = {"namespace" => '', "metricname" => '', "dimension-value" => ''}
|
|
35
|
+
lambda {ZabbixCloudwatch::GetCloudwatchMetric.new(options)}.should raise_error GetCloudwatchMetric::DimensionArgumentMissingException
|
|
36
|
+
end
|
|
37
|
+
it "Raises Exception when aws keys are not in options" do
|
|
38
|
+
options = {"namespace" => '', "metricname" => '', "dimension-value" => '', "dimension-name" => ''}
|
|
39
|
+
lambda {ZabbixCloudwatch::GetCloudwatchMetric.new(options)}.should raise_error GetCloudwatchMetric::AwsAccessKeyMissingException
|
|
40
|
+
options = {"namespace" => '', "metricname" => '', "dimension-value" => '', "dimension-name" => '', "aws-access-key" => ''}
|
|
41
|
+
lambda {ZabbixCloudwatch::GetCloudwatchMetric.new(options)}.should raise_error GetCloudwatchMetric::AwsSecretKeyMissingException
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
describe "#time_now" do
|
|
45
|
+
it "Should return an ISO8601 date in UTC" do
|
|
46
|
+
options = {"namespace" => 'AWS/EC2', "metricname" => 'CPU', "dimension-value" => 'EC2Instance', "dimension-name" => 'test', "aws-access-key" => 'test', "aws-secret-key" => 'test'}
|
|
47
|
+
ZabbixCloudwatch::GetCloudwatchMetric.new(options).time_now.should =~ /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
describe "#time_one_minute_ago" do
|
|
51
|
+
it "Should return an ISO8601 date in UTC" do
|
|
52
|
+
options = {"namespace" => 'AWS/EC2', "metricname" => 'CPU', "dimension-value" => 'EC2Instance', "dimension-name" => 'test', "aws-access-key" => 'test', "aws-secret-key" => 'test'}
|
|
53
|
+
ZabbixCloudwatch::GetCloudwatchMetric.new(options).time_one_minute_ago.should =~ /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
describe "#time_five_minutes_ago" do
|
|
57
|
+
it "Should return an ISO8601 date in UTC" do
|
|
58
|
+
options = {"namespace" => 'AWS/EC2', "metricname" => 'CPU', "dimension-value" => 'EC2Instance', "dimension-name" => 'test', "aws-access-key" => 'test', "aws-secret-key" => 'test'}
|
|
59
|
+
ZabbixCloudwatch::GetCloudwatchMetric.new(options).time_five_minutes_ago.should =~ /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
describe "#set_time_range" do
|
|
63
|
+
it "Should set a start_time and end_time that is 450 seconds apart when the monitoring-type is not set" do
|
|
64
|
+
options = {"namespace" => 'AWS/EC2', "metricname" => 'CPU', "dimension-value" => 'EC2Instance', "dimension-name" => 'test', "aws-access-key" => 'test', "aws-secret-key" => 'test'}
|
|
65
|
+
@inst = ZabbixCloudwatch::GetCloudwatchMetric.new(options)
|
|
66
|
+
@inst.set_time_range
|
|
67
|
+
(Time.iso8601(@inst.end_time).to_i - Time.iso8601(@inst.start_time).to_i).should eq(450)
|
|
68
|
+
end
|
|
69
|
+
it "Should set a start_time and end_time that is 450 seconds apart when the monitoring-type is set to basic" do
|
|
70
|
+
options = {"namespace" => 'AWS/EC2', "metricname" => 'CPU', "dimension-value" => 'EC2Instance', "dimension-name" => 'test', "aws-access-key" => 'test', "aws-secret-key" => 'test', "monitoring-type" => 'basic'}
|
|
71
|
+
@inst = ZabbixCloudwatch::GetCloudwatchMetric.new(options)
|
|
72
|
+
@inst.set_time_range
|
|
73
|
+
(Time.iso8601(@inst.end_time).to_i - Time.iso8601(@inst.start_time).to_i).should eq(450)
|
|
74
|
+
end
|
|
75
|
+
it "Should set a start_time and end_time that is 90 seconds apart when the monitoring-type is set to detailed" do
|
|
76
|
+
options = {"namespace" => 'AWS/EC2', "metricname" => 'CPU', "dimension-value" => 'EC2Instance', "dimension-name" => 'test', "aws-access-key" => 'test', "aws-secret-key" => 'test', "monitoring-type" => 'detailed'}
|
|
77
|
+
@inst = ZabbixCloudwatch::GetCloudwatchMetric.new(options)
|
|
78
|
+
@inst.set_time_range
|
|
79
|
+
(Time.iso8601(@inst.end_time).to_i - Time.iso8601(@inst.start_time).to_i).should eq(90)
|
|
80
|
+
end
|
|
81
|
+
it "Should raise a MonitoringTypeArgumentException when the monitoring-type is not set to either basic or detailed" do
|
|
82
|
+
options = {"namespace" => 'AWS/EC2', "metricname" => 'CPU', "dimension-value" => 'EC2Instance', "dimension-name" => 'test', "aws-access-key" => 'test', "aws-secret-key" => 'test', "monitoring-type" => 'junk'}
|
|
83
|
+
@inst = ZabbixCloudwatch::GetCloudwatchMetric.new(options)
|
|
84
|
+
lambda {@inst.set_time_range}.should raise_error GetCloudwatchMetric::MonitoringTypeArgumentException
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
describe "#set_statistic" do
|
|
88
|
+
it "Should set the statistic type to Average when statistic option is not set" do
|
|
89
|
+
options = {"namespace" => 'AWS/EC2', "metricname" => 'CPU', "dimension-value" => 'EC2Instance', "dimension-name" => 'test', "aws-access-key" => 'test', "aws-secret-key" => 'test'}
|
|
90
|
+
@inst = ZabbixCloudwatch::GetCloudwatchMetric.new(options)
|
|
91
|
+
@inst.set_statistic
|
|
92
|
+
@inst.statistic.should eq("Average")
|
|
93
|
+
end
|
|
94
|
+
it "Should set the statistic type to Sum when statistic option is set to Sum" do
|
|
95
|
+
options = {"namespace" => 'AWS/EC2', "metricname" => 'CPU', "dimension-value" => 'EC2Instance', "dimension-name" => 'test', "aws-access-key" => 'test', "aws-secret-key" => 'test', "statistic" => "Sum"}
|
|
96
|
+
@inst = ZabbixCloudwatch::GetCloudwatchMetric.new(options)
|
|
97
|
+
@inst.set_statistic
|
|
98
|
+
@inst.statistic.should eq("Sum")
|
|
99
|
+
end
|
|
100
|
+
it "Should raise a StatisticTypeArgumentException when the statistic option is not set to one of 'Minimum, Maximum, Average, Sum, SampleCount" do
|
|
101
|
+
options = {"namespace" => 'AWS/EC2', "metricname" => 'CPU', "dimension-value" => 'EC2Instance', "dimension-name" => 'test', "aws-access-key" => 'test', "aws-secret-key" => 'test', "statistic" => "Test"}
|
|
102
|
+
@inst = ZabbixCloudwatch::GetCloudwatchMetric.new(options)
|
|
103
|
+
lambda {@inst.set_statistic}.should raise_error GetCloudwatchMetric::StatisticTypeArgumentException
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
describe "#run! (real)" do
|
|
107
|
+
it "Raises BadAWSAccessKeysException when the AWS Keys and/or Region are incorrect in the options" do
|
|
108
|
+
options = {"namespace" => '', "metricname" => '', "dimension-value" => '', "dimension-name" => '', "aws-access-key" => '', "aws-secret-key" => ''}
|
|
109
|
+
lambda {ZabbixCloudwatch::GetCloudwatchMetric.new(options).run!}.should raise_error GetCloudwatchMetric::BadAWSAccessKeysException
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
describe "#test_aws_connectivity (real)" do
|
|
113
|
+
it "Raises BadAWSAccessKeysException when the AWS Keys and/or Region are incorrect in the options" do
|
|
114
|
+
options = {"namespace" => '', "metricname" => '', "dimension-value" => '', "dimension-name" => '', "aws-access-key" => '', "aws-secret-key" => ''}
|
|
115
|
+
lambda {ZabbixCloudwatch::GetCloudwatchMetric.new(options).test_aws_connectivity}.should raise_error GetCloudwatchMetric::BadAWSAccessKeysException
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
describe "#test_aws_connectivity (mock)" do
|
|
119
|
+
it "Tests connectivity to AWS" do
|
|
120
|
+
options = {"namespace" => '', "metricname" => '', "dimension-value" => '', "dimension-name" => '', "aws-access-key" => '', "aws-secret-key" => ''}
|
|
121
|
+
AWS.stub!
|
|
122
|
+
@inst = ZabbixCloudwatch::GetCloudwatchMetric.new(options)
|
|
123
|
+
lambda {@inst.test_aws_connectivity}.should_not raise_error
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
describe "#run! (mock)" do
|
|
127
|
+
before(:each) do
|
|
128
|
+
options = {"namespace" => 'AWS/EC2', "metricname" => 'CPU', "dimension-value" => 'EC2Instance', "dimension-name" => 'test', "aws-access-key" => 'test', "aws-secret-key" => 'test'}
|
|
129
|
+
AWS.stub!
|
|
130
|
+
@inst = ZabbixCloudwatch::GetCloudwatchMetric.new(options)
|
|
131
|
+
@stb = @inst.aws.stub_for(:get_metric_statistics)
|
|
132
|
+
end
|
|
133
|
+
it "exits 1 when there are no datapoints" do
|
|
134
|
+
@stb.data = Hash.new
|
|
135
|
+
lambda {@inst.run!}.should raise_error SystemExit
|
|
136
|
+
end
|
|
137
|
+
it "puts a string when there is one datapoint" do
|
|
138
|
+
@stb.data = {:datapoints => [ { :average => '10.0' } ] }
|
|
139
|
+
output = capture_stdout {@inst.run!}
|
|
140
|
+
output.should eq("10.0\n")
|
|
141
|
+
end
|
|
142
|
+
it "puts the first datapoint when there is more than one datapoint returned by AWS" do
|
|
143
|
+
@stb.data = {:datapoints => [ { :average => '10.0' }, {:average => '10.1'}, {:average => '10.2'}] }
|
|
144
|
+
output = capture_stdout {@inst.run!}
|
|
145
|
+
output.should eq("10.0\n")
|
|
146
|
+
end
|
|
147
|
+
it "puts the metric that matches the statistic" do
|
|
148
|
+
@stb.data = {:datapoints => [ { :average => '10.0', :minimum => '10.1', :maximum => '10.2', :sample_count => '10.3', :sum => '10.4' } ] }
|
|
149
|
+
output = capture_stdout {@inst.run!}
|
|
150
|
+
output.should eq("10.0\n")
|
|
151
|
+
@inst.options["statistic"] = "Minimum"
|
|
152
|
+
output = capture_stdout {@inst.run!}
|
|
153
|
+
output.should eq("10.1\n")
|
|
154
|
+
@inst.options["statistic"] = "Maximum"
|
|
155
|
+
output = capture_stdout {@inst.run!}
|
|
156
|
+
output.should eq("10.2\n")
|
|
157
|
+
@inst.options["statistic"] = "SampleCount"
|
|
158
|
+
output = capture_stdout {@inst.run!}
|
|
159
|
+
output.should eq("10.3\n")
|
|
160
|
+
@inst.options["statistic"] = "Sum"
|
|
161
|
+
output = capture_stdout {@inst.run!}
|
|
162
|
+
output.should eq("10.4\n")
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
data/zabbix-cloudwatch.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zabbix-cloudwatch
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Randy D. Wallace Jr.
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2013-10-
|
|
12
|
+
date: 2013-10-28 00:00:00 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: aws-sdk
|
|
@@ -31,6 +31,17 @@ dependencies:
|
|
|
31
31
|
version: 1.4.1
|
|
32
32
|
type: :runtime
|
|
33
33
|
version_requirements: *id002
|
|
34
|
+
- !ruby/object:Gem::Dependency
|
|
35
|
+
name: rspec
|
|
36
|
+
prerelease: false
|
|
37
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- &id004
|
|
40
|
+
- ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: "0"
|
|
43
|
+
type: :development
|
|
44
|
+
version_requirements: *id003
|
|
34
45
|
description: |
|
|
35
46
|
A library for getting cloudwatch metrics into Zabbix
|
|
36
47
|
|
|
@@ -53,6 +64,8 @@ files:
|
|
|
53
64
|
- bin/zabbix-cloudwatch
|
|
54
65
|
- lib/zabbix-cloudwatch.rb
|
|
55
66
|
- lib/zabbix-cloudwatch/version.rb
|
|
67
|
+
- spec/spec_helper.rb
|
|
68
|
+
- spec/zabbix-cloudwatch/zabbix-cloudwatch_spec.rb
|
|
56
69
|
- zabbix-cloudwatch.gemspec
|
|
57
70
|
homepage: http://github.com/randywallace/zabbix-cloudwatch
|
|
58
71
|
licenses:
|
|
@@ -66,13 +79,10 @@ require_paths:
|
|
|
66
79
|
- lib
|
|
67
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
81
|
requirements:
|
|
69
|
-
-
|
|
70
|
-
- ">="
|
|
71
|
-
- !ruby/object:Gem::Version
|
|
72
|
-
version: "0"
|
|
82
|
+
- *id004
|
|
73
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
84
|
requirements:
|
|
75
|
-
- *
|
|
85
|
+
- *id004
|
|
76
86
|
requirements: []
|
|
77
87
|
|
|
78
88
|
rubyforge_project:
|