radiosonde 0.1.1 → 0.2.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/radiosonde +4 -4
- data/lib/radiosonde.rb +1 -1
- data/lib/radiosonde/client.rb +26 -32
- data/lib/radiosonde/dsl/context/alarm.rb +1 -1
- data/lib/radiosonde/exporter.rb +5 -3
- data/lib/radiosonde/ext/cloud_watch_ext.rb +1 -1
- data/lib/radiosonde/version.rb +1 -1
- data/lib/radiosonde/wrapper/alarm.rb +2 -2
- data/lib/radiosonde/wrapper/alarm_collection.rb +8 -8
- data/lib/radiosonde/wrapper/cloud_watch.rb +1 -1
- data/radiosonde.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fd996f58c5a00b537d2e18788677303e682443f
|
4
|
+
data.tar.gz: 6c697fdec4968eb129539b4fb76ae51b38d3a9ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7471238fc343fd02749a154281fe0029a778eebe65d97d178355aae08101ac970a6b6b95c730312d3673a08063d04c82dccf0268b531e32f5a63408a9fa59ee
|
7
|
+
data.tar.gz: 619cbd2478165ebaa7ac8f4f064bce83d7572d42407e33f747388b6de46a8078e5dc322166faf032e51163304098b403ff93bcfe2141993a9087dc1c598a41aa
|
data/bin/radiosonde
CHANGED
@@ -71,17 +71,17 @@ ARGV.options do |opt|
|
|
71
71
|
:secret_access_key => secret_key
|
72
72
|
)
|
73
73
|
elsif profile_name
|
74
|
-
|
74
|
+
credentials = Aws::SharedCredentials.new(
|
75
75
|
:profile_name => profile_name
|
76
76
|
)
|
77
|
-
aws_opts[:
|
77
|
+
aws_opts[:credentials] = credentials
|
78
78
|
elsif (access_key and !secret_key) or (!access_key and secret_key) or mode.nil?
|
79
79
|
puts opt.help
|
80
80
|
exit 1
|
81
81
|
end
|
82
82
|
|
83
83
|
aws_opts[:region] = region if region
|
84
|
-
|
84
|
+
Aws.config.update(aws_opts)
|
85
85
|
rescue => e
|
86
86
|
$stderr.puts("[ERROR] #{e.message}")
|
87
87
|
exit 1
|
@@ -91,7 +91,7 @@ end
|
|
91
91
|
String.colorize = options[:color]
|
92
92
|
|
93
93
|
if options[:debug]
|
94
|
-
|
94
|
+
Aws.config.update({
|
95
95
|
:http_wire_trace => true,
|
96
96
|
:logger => Radiosonde::Logger.instance,
|
97
97
|
})
|
data/lib/radiosonde.rb
CHANGED
data/lib/radiosonde/client.rb
CHANGED
@@ -4,15 +4,13 @@ class Radiosonde::Client
|
|
4
4
|
|
5
5
|
def initialize(options = {})
|
6
6
|
@options = options
|
7
|
-
@cloud_watch =
|
7
|
+
@cloud_watch = Aws::CloudWatch::Client.new
|
8
8
|
end
|
9
9
|
|
10
10
|
def export(opts = {})
|
11
11
|
exported = nil
|
12
12
|
|
13
|
-
|
14
|
-
exported = Radiosonde::Exporter.export(@cloud_watch, @options.merge(opts))
|
15
|
-
end
|
13
|
+
exported = Radiosonde::Exporter.export(@cloud_watch, @options.merge(opts))
|
16
14
|
|
17
15
|
Radiosonde::DSL.convert(exported, @options.merge(opts))
|
18
16
|
end
|
@@ -20,34 +18,30 @@ class Radiosonde::Client
|
|
20
18
|
def metrics(opts = {})
|
21
19
|
namespaces = {}
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
statistics_ops = {}
|
36
|
-
[:start_time, :end_time, :statistics].each do |name|
|
37
|
-
statistics_ops[name] = opts[name] if opts[name]
|
38
|
-
end
|
39
|
-
statistics = m.statistics(statistics_ops)
|
40
|
-
namespaces[m.namespace][m.metric_name] = {
|
41
|
-
:label => statistics.label,
|
42
|
-
:datapoints => statistics.datapoints
|
43
|
-
}
|
44
|
-
elsif opts[:with_dimensions]
|
45
|
-
namespaces[m.namespace] ||= {}
|
46
|
-
namespaces[m.namespace][m.metric_name] = m.dimensions
|
47
|
-
else
|
48
|
-
namespaces[m.namespace] ||= []
|
49
|
-
namespaces[m.namespace] << m.metric_name
|
21
|
+
ms = @cloud_watch.list_metrics(namespace: opts[:namespace], metric_name: opts[:metric_name]).flat_map(&:metrics)
|
22
|
+
ms.sort_by {|m| [m.namespace, m.metric_name] }.each do |m|
|
23
|
+
if opts[:with_statistics]
|
24
|
+
namespaces[m.namespace] ||= {}
|
25
|
+
statistics_ops = {
|
26
|
+
namespace: opts[:namespace],
|
27
|
+
metric_name: opts[:metric_name],
|
28
|
+
period: 60,
|
29
|
+
dimensions: m.dimensions,
|
30
|
+
}
|
31
|
+
[:start_time, :end_time, :statistics].each do |name|
|
32
|
+
statistics_ops[name] = opts[name] if opts[name]
|
50
33
|
end
|
34
|
+
statistics = @cloud_watch.get_metric_statistics(statistics_ops)
|
35
|
+
namespaces[m.namespace][m.metric_name] = {
|
36
|
+
label: statistics.label,
|
37
|
+
datapoints: statistics.datapoints.map(&:to_h),
|
38
|
+
}
|
39
|
+
elsif opts[:with_dimensions]
|
40
|
+
namespaces[m.namespace] ||= {}
|
41
|
+
namespaces[m.namespace][m.metric_name] = m.dimensions.map(&:to_h)
|
42
|
+
else
|
43
|
+
namespaces[m.namespace] ||= []
|
44
|
+
namespaces[m.namespace] << m.metric_name
|
51
45
|
end
|
52
46
|
end
|
53
47
|
|
@@ -55,7 +49,7 @@ class Radiosonde::Client
|
|
55
49
|
end
|
56
50
|
|
57
51
|
def apply(file)
|
58
|
-
|
52
|
+
walk(file)
|
59
53
|
end
|
60
54
|
|
61
55
|
private
|
data/lib/radiosonde/exporter.rb
CHANGED
@@ -15,9 +15,11 @@ class Radiosonde::Exporter
|
|
15
15
|
def export
|
16
16
|
result = {}
|
17
17
|
|
18
|
-
@cloud_watch.
|
19
|
-
|
20
|
-
|
18
|
+
@cloud_watch.describe_alarms.each do |page|
|
19
|
+
page.metric_alarms.each do |alarm|
|
20
|
+
if matched?(alarm.alarm_name, @options[:include], @options[:exclude])
|
21
|
+
export_alarm(alarm, result)
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
data/lib/radiosonde/version.rb
CHANGED
@@ -63,7 +63,7 @@ class Radiosonde::Wrapper::Alarm
|
|
63
63
|
|
64
64
|
unless @options[:dry_run]
|
65
65
|
opts = self.class.normalize_attrs(dsl)
|
66
|
-
@
|
66
|
+
@cloud_watch.put_metric_alarm(opts.merge(alarm_name: alarm_name))
|
67
67
|
@cloud_watch.modify!
|
68
68
|
end
|
69
69
|
end
|
@@ -72,7 +72,7 @@ class Radiosonde::Wrapper::Alarm
|
|
72
72
|
log(:info, 'Delete Alarm', :red, self.alarm_name)
|
73
73
|
|
74
74
|
unless @options[:dry_run]
|
75
|
-
@
|
75
|
+
@cloud_watch.delete_alarms(alarm_names: [alarm_name])
|
76
76
|
@cloud_watch.modify!
|
77
77
|
end
|
78
78
|
end
|
@@ -1,15 +1,16 @@
|
|
1
1
|
class Radiosonde::Wrapper::AlarmCollection
|
2
2
|
include Radiosonde::Logger::Helper
|
3
3
|
|
4
|
-
def initialize(cloud_watch,
|
4
|
+
def initialize(cloud_watch, options = {})
|
5
5
|
@cloud_watch = cloud_watch
|
6
|
-
@alarms = alarms
|
7
6
|
@options = options
|
8
7
|
end
|
9
8
|
|
10
9
|
def each
|
11
|
-
@
|
12
|
-
|
10
|
+
@cloud_watch.describe_alarms.each do |page|
|
11
|
+
page.metric_alarms.each do |alarm|
|
12
|
+
yield(Radiosonde::Wrapper::Alarm.new(@cloud_watch, alarm, @options))
|
13
|
+
end
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -17,10 +18,9 @@ class Radiosonde::Wrapper::AlarmCollection
|
|
17
18
|
log(:info, 'Create Alarm', :cyan, name)
|
18
19
|
opts = Radiosonde::Wrapper::Alarm.normalize_attrs(dsl)
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
alarm = @alarms.create(name, opts)
|
21
|
+
alarm = Aws::CloudWatch::Types::MetricAlarm.new(opts.merge(alarm_name: name))
|
22
|
+
unless @options[:dry_run]
|
23
|
+
@cloud_watch.put_metric_alarm(alarm.to_h)
|
24
24
|
@cloud_watch.modify!
|
25
25
|
end
|
26
26
|
|
data/radiosonde.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'aws-sdk-
|
21
|
+
spec.add_dependency 'aws-sdk-core', '>= 2.1.0'
|
22
22
|
spec.add_dependency 'json'
|
23
23
|
spec.add_dependency 'term-ansicolor'
|
24
24
|
spec.add_dependency 'diffy'
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiosonde
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: aws-sdk-
|
14
|
+
name: aws-sdk-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,9 +177,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
177
|
version: '0'
|
178
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
179
|
requirements:
|
180
|
-
- - "
|
180
|
+
- - ">"
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version:
|
182
|
+
version: 1.3.1
|
183
183
|
requirements: []
|
184
184
|
rubyforge_project:
|
185
185
|
rubygems_version: 2.4.5.1
|