aws-sdk-cloudwatch 0.0.6 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/aws-sdk-cloudwatch.rb +50 -0
- data/lib/aws-sdk-cloudwatch/alarm.rb +451 -0
- data/lib/aws-sdk-cloudwatch/client.rb +986 -0
- data/lib/aws-sdk-cloudwatch/client_api.rb +421 -0
- data/lib/aws-sdk-cloudwatch/customizations.rb +7 -0
- data/lib/aws-sdk-cloudwatch/errors.rb +23 -0
- data/lib/aws-sdk-cloudwatch/metric.rb +424 -0
- data/lib/aws-sdk-cloudwatch/resource.rb +123 -0
- data/lib/aws-sdk-cloudwatch/types.rb +1024 -0
- data/lib/aws-sdk-cloudwatch/waiters.rb +50 -0
- metadata +35 -106
- data/.gitignore +0 -4
- data/CHANGELOG +0 -6
- data/Gemfile +0 -18
- data/LICENSE.txt +0 -202
- data/NOTICE.txt +0 -2
- data/README.rdoc +0 -41
- data/Rakefile +0 -23
- data/aws-sdk-cloudwatch.gemspec +0 -36
- data/lib/aws/api_config/CloudWatch-2010-08-01.yml +0 -359
- data/lib/aws/cloud_watch.rb +0 -31
- data/lib/aws/cloud_watch/client.rb +0 -57
- data/lib/aws/cloud_watch/config.rb +0 -19
- data/lib/aws/cloud_watch/ec2.rb +0 -58
- data/lib/aws/cloud_watch/errors.rb +0 -23
- data/lib/aws/cloud_watch/metric.rb +0 -97
- data/lib/aws/cloud_watch/metric_base.rb +0 -100
- data/lib/aws/cloud_watch/metric_collection.rb +0 -48
- data/lib/aws/cloud_watch/request.rb +0 -30
- data/lib/aws/core/option_grammar/double.rb +0 -29
- data/licence.rb +0 -14
- data/spec/cloud_watch_client_spec.rb +0 -27
- data/spec/cloud_watch_ec2_spec.rb +0 -70
- data/spec/metric_base_spec.rb +0 -50
- data/spec/metric_collection_spec.rb +0 -46
- data/spec/metric_spec.rb +0 -159
data/lib/aws/cloud_watch.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# Copyright 2012 Inscitiv
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'aws/core'
|
16
|
-
require 'aws/cloud_watch/config'
|
17
|
-
|
18
|
-
module AWS
|
19
|
-
class CloudWatch
|
20
|
-
AWS::register_autoloads(self, 'aws/cloud_watch') do
|
21
|
-
autoload :Client, 'client'
|
22
|
-
autoload :Errors, 'errors'
|
23
|
-
autoload :Metric, 'metric'
|
24
|
-
autoload :MetricBase, 'metric_base'
|
25
|
-
autoload :MetricCollection, 'metric_collection'
|
26
|
-
autoload :Request, 'request'
|
27
|
-
end
|
28
|
-
|
29
|
-
include Core::ServiceInterface
|
30
|
-
end
|
31
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# Copyright 2012 Inscitiv
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'aws/core'
|
16
|
-
require 'aws/core/client/query_xml'
|
17
|
-
require 'aws/core/option_grammar/double'
|
18
|
-
require 'yaml'
|
19
|
-
|
20
|
-
module AWS
|
21
|
-
class CloudWatch
|
22
|
-
|
23
|
-
class Client < Core::Client
|
24
|
-
|
25
|
-
# this is copied from 'aws/core/client'; it's needed,
|
26
|
-
# otherwise it searches in the original gem directory
|
27
|
-
def self.api_config
|
28
|
-
config_file =
|
29
|
-
File.dirname(File.dirname(__FILE__)) +
|
30
|
-
"/api_config/#{service_name}-#{self::API_VERSION}.yml"
|
31
|
-
YAML.load(File.read(config_file))
|
32
|
-
end
|
33
|
-
|
34
|
-
API_VERSION = '2010-08-01'
|
35
|
-
|
36
|
-
extend Core::Client::QueryXML
|
37
|
-
|
38
|
-
CACHEABLE_REQUESTS = Set[
|
39
|
-
# TODO
|
40
|
-
]
|
41
|
-
|
42
|
-
define_client_method :delete_alarms, 'DeleteAlarms'
|
43
|
-
define_client_method :describe_alarm_history, 'DescribeAlarmHistory'
|
44
|
-
define_client_method :describe_alarms, 'DescribeAlarms'
|
45
|
-
define_client_method :describe_alarms_for_metric, 'DescribeAlarmsForMetric'
|
46
|
-
define_client_method :disable_alarm_actions, 'DisableAlarmActions'
|
47
|
-
define_client_method :enable_alarm_actions, 'EnableAlarmActions'
|
48
|
-
define_client_method :get_metric_statistics, 'GetMetricStatistics'
|
49
|
-
define_client_method :list_metrics, 'ListMetrics'
|
50
|
-
define_client_method :put_metric_alarm, 'PutMetricAlarm'
|
51
|
-
define_client_method :put_metric_data, 'PutMetricData'
|
52
|
-
define_client_method :set_alarm_state, 'SetAlarmState'
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# Copyright 2012 Inscitiv
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
AWS::Core::Configuration.module_eval do
|
16
|
-
|
17
|
-
add_service 'CloudWatch', 'cloud_watch', 'monitoring.us-east-1.amazonaws.com'
|
18
|
-
|
19
|
-
end
|
data/lib/aws/cloud_watch/ec2.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# Copyright 2012 Inscitiv
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'aws/cloud_watch'
|
16
|
-
require 'aws/ec2'
|
17
|
-
|
18
|
-
module AWS
|
19
|
-
class CloudWatch
|
20
|
-
module EC2
|
21
|
-
|
22
|
-
def metrics
|
23
|
-
@metrics ||= MetricCollection.new :namespace => 'AWS/EC2', :instance_id => id, :config => config
|
24
|
-
end
|
25
|
-
|
26
|
-
def cpu_utilization *args
|
27
|
-
metric = metrics['CPUUtilization']
|
28
|
-
if args.length == 0
|
29
|
-
metric
|
30
|
-
else
|
31
|
-
metric.average *args
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def method_missing name, *args
|
36
|
-
if [:disk_read_ops, :disk_write_ops, :network_out, :disk_read_bytes, :network_in, :disk_write_bytes].include?(name)
|
37
|
-
metric = metrics[name]
|
38
|
-
if args.length == 0
|
39
|
-
metric
|
40
|
-
else
|
41
|
-
metric.sum *args
|
42
|
-
end
|
43
|
-
else
|
44
|
-
super
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
require 'aws/ec2/resource'
|
53
|
-
require 'aws/ec2/tagged_item'
|
54
|
-
require 'aws/ec2/instance'
|
55
|
-
|
56
|
-
AWS::EC2::Instance.class_eval do
|
57
|
-
include AWS::CloudWatch::EC2
|
58
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# Copyright 2012 Inscitiv
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module AWS
|
16
|
-
class CloudWatch
|
17
|
-
module Errors
|
18
|
-
|
19
|
-
extend Core::LazyErrorClasses
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
# Copyright 2012 Inscitiv
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'aws/core/inflection'
|
16
|
-
require 'time'
|
17
|
-
|
18
|
-
module AWS
|
19
|
-
class CloudWatch
|
20
|
-
class Metric < MetricBase
|
21
|
-
|
22
|
-
attr_accessor :unit
|
23
|
-
|
24
|
-
def options
|
25
|
-
super.merge(unit ? {:unit => unit} : {})
|
26
|
-
end
|
27
|
-
|
28
|
-
def attr_names
|
29
|
-
super + [:unit]
|
30
|
-
end
|
31
|
-
|
32
|
-
MAX_RECORDS = 1440
|
33
|
-
|
34
|
-
def get statistics, period, range = Time.now, opts = {}
|
35
|
-
statistics = [statistics] unless statistics.kind_of? Array
|
36
|
-
unless range.kind_of? Range
|
37
|
-
range = (range - period)..range
|
38
|
-
single_point = true
|
39
|
-
else
|
40
|
-
single_point = false
|
41
|
-
end
|
42
|
-
single_point &&= statistics.length == 1
|
43
|
-
|
44
|
-
def get_batch statistics, period, range, opts
|
45
|
-
options = self.options.merge({
|
46
|
-
:end_time => range.end.getutc.iso8601,
|
47
|
-
:start_time => range.begin.getutc.iso8601,
|
48
|
-
:period => period.to_i,
|
49
|
-
:statistics => statistics.map { |s| camel_case(s) } })
|
50
|
-
options[:unit] = camel_case(opts[:unit]) if opts[:unit]
|
51
|
-
return [] if options[:end_time] == options[:start_time]
|
52
|
-
|
53
|
-
data = client.get_metric_statistics(options).datapoints
|
54
|
-
end
|
55
|
-
|
56
|
-
if single_point
|
57
|
-
data = get_batch statistics, period, range, opts
|
58
|
-
|
59
|
-
if data.length == 0
|
60
|
-
return nil
|
61
|
-
else
|
62
|
-
return data[0][statistics[0]]
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
return [] if range.begin + period > range.end
|
67
|
-
|
68
|
-
max_period = MAX_RECORDS * period / statistics.length
|
69
|
-
|
70
|
-
ranges = [range]
|
71
|
-
while (ranges[-1].end - ranges[-1].begin) > max_period
|
72
|
-
range = ranges.pop
|
73
|
-
pivot = range.begin + max_period
|
74
|
-
ranges.push range.begin..pivot
|
75
|
-
ranges.push pivot..range.end
|
76
|
-
end
|
77
|
-
|
78
|
-
ranges.map{|range| get_batch statistics, period, range, opts}.flatten.sort{|a, b| a[:timestamp] <=> b[:timestamp]}
|
79
|
-
end
|
80
|
-
|
81
|
-
def method_missing name, *args
|
82
|
-
if [:average, :sum, :sample_count, :maximum, :minimum].include?(name)
|
83
|
-
data = get name, *args
|
84
|
-
if data.kind_of? Array
|
85
|
-
data.each do |point|
|
86
|
-
point[:value] = point[name]
|
87
|
-
end
|
88
|
-
end
|
89
|
-
data
|
90
|
-
else
|
91
|
-
super
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
# Copyright 2012 Inscitiv
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'aws/core/inflection'
|
16
|
-
|
17
|
-
module AWS
|
18
|
-
class CloudWatch
|
19
|
-
|
20
|
-
# @private
|
21
|
-
class MetricBase
|
22
|
-
include Core::Model
|
23
|
-
|
24
|
-
def initialize options
|
25
|
-
super
|
26
|
-
@dimensions = {}
|
27
|
-
set_attributes options
|
28
|
-
end
|
29
|
-
|
30
|
-
def set_attributes attrs
|
31
|
-
attrs.keys.each do |k|
|
32
|
-
key = k
|
33
|
-
key = :name if key == :metric_name
|
34
|
-
if key.kind_of? Symbol
|
35
|
-
send("#{key}=", attrs[k]) unless key == :config
|
36
|
-
else
|
37
|
-
dimensions[key] = attrs[k]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
attr_accessor :name, :namespace
|
43
|
-
attr_reader :dimensions
|
44
|
-
|
45
|
-
def dimensions= value
|
46
|
-
if value.kind_of? Array
|
47
|
-
hash = {}
|
48
|
-
value.each do |entry|
|
49
|
-
hash[entry[:name]] = entry[:value]
|
50
|
-
end
|
51
|
-
value = hash
|
52
|
-
end
|
53
|
-
|
54
|
-
@dimensions = value
|
55
|
-
end
|
56
|
-
|
57
|
-
def attr_names
|
58
|
-
[:dimensions, :name, :namespace]
|
59
|
-
end
|
60
|
-
|
61
|
-
def method_missing name, *args
|
62
|
-
if args.length == 1 && name.to_s =~ /^(.*)=/ then
|
63
|
-
@dimensions[$1.to_sym] = args[0]
|
64
|
-
else
|
65
|
-
super
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def options
|
70
|
-
opts = !dimensions.empty? ? {:dimensions =>
|
71
|
-
dimensions.keys.map {|key|
|
72
|
-
{ :name => camel_case(key),
|
73
|
-
:value => dimensions[key] }}
|
74
|
-
} : {}
|
75
|
-
|
76
|
-
opts[:metric_name] = name if name
|
77
|
-
opts[:namespace] = namespace if namespace
|
78
|
-
opts
|
79
|
-
end
|
80
|
-
|
81
|
-
def camel_case s
|
82
|
-
Core::Inflection.class_name s.to_s
|
83
|
-
end
|
84
|
-
|
85
|
-
def to_sym s
|
86
|
-
Core::Inflection.ruby_name(s.to_s).to_sym
|
87
|
-
end
|
88
|
-
|
89
|
-
def inspect
|
90
|
-
attrs = []
|
91
|
-
attr_names.each do |attr|
|
92
|
-
val = self.send attr
|
93
|
-
attrs << "#{attr}:#{val.inspect}" if val
|
94
|
-
end
|
95
|
-
|
96
|
-
"<#{self::class} #{attrs.join ' '}>"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# Copyright 2012 Inscitiv
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module AWS
|
16
|
-
class CloudWatch
|
17
|
-
class MetricCollection < MetricBase
|
18
|
-
|
19
|
-
include Enumerable
|
20
|
-
|
21
|
-
def each &block
|
22
|
-
|
23
|
-
next_token = nil
|
24
|
-
|
25
|
-
begin
|
26
|
-
|
27
|
-
list_options = options.merge(next_token ? { :next_token => next_token } : {})
|
28
|
-
response = client.list_metrics(list_options)
|
29
|
-
|
30
|
-
response.metrics.each do |t|
|
31
|
-
metric = Metric.new(t.merge :config => config)
|
32
|
-
yield(metric)
|
33
|
-
end
|
34
|
-
|
35
|
-
end while(next_token = response.data[:next_token])
|
36
|
-
nil
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
def get_by_name name
|
41
|
-
Metric.new(options.merge(:name => camel_case(name), :config => config))
|
42
|
-
end
|
43
|
-
|
44
|
-
alias_method :[], :get_by_name
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# Copyright 2012 Inscitiv
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module AWS
|
16
|
-
class CloudWatch
|
17
|
-
|
18
|
-
# @private
|
19
|
-
class Request < Core::Http::Request
|
20
|
-
|
21
|
-
include Core::Signature::Version4
|
22
|
-
|
23
|
-
def service
|
24
|
-
'monitoring'
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|