bin/radiosonde in radiosonde-0.0.1 vs bin/radiosonde in radiosonde-0.0.2
- old
+ new
@@ -1,10 +1,12 @@
#!/usr/bin/env ruby
$: << File.expand_path("#{File.dirname __FILE__}/../lib")
require 'rubygems'
require 'radiosonde'
require 'optparse'
+require 'optparse/time'
+require 'time'
Version = Radiosonde::VERSION
DEFAULT_FILENAME = 'Alarmfile'
mode = nil
@@ -15,28 +17,45 @@
:dry_run => false,
:color => true,
:debug => false,
}
+show_opts = {
+ :start_time => Time.now - 3600,
+ :end_time => Time.now,
+ :statistic => :average,
+}
+
ARGV.options do |opt|
begin
access_key = nil
secret_key = nil
region = nil
profile_name = nil
- opt.on('-p', '--profile PROFILE_NAME') {|v| profile_name = v }
- opt.on('-k', '--access-key ACCESS_KEY') {|v| access_key = v }
- opt.on('-s', '--secret-key SECRET_KEY') {|v| secret_key = v }
- opt.on('-r', '--region REGION') {|v| region = v }
- opt.on('-a', '--apply') { mode = :apply }
- opt.on('-f', '--file FILE') {|v| file = v }
- opt.on('', '--dry-run') { options[:dry_run] = true }
- opt.on('-e', '--export') { mode = :export }
- opt.on('-o', '--output FILE') {|v| output_file = v }
- opt.on('' , '--no-color') { options[:color] = false }
- opt.on('' , '--debug') { options[:debug] = true }
+ opt.on('-p', '--profile PROFILE_NAME') {|v| profile_name = v }
+ opt.on('-k', '--access-key ACCESS_KEY') {|v| access_key = v }
+ opt.on('-s', '--secret-key SECRET_KEY') {|v| secret_key = v }
+ opt.on('-r', '--region REGION') {|v| region = v }
+ opt.on('-a', '--apply') { mode = :apply }
+ opt.on('-f', '--file FILE') {|v| file = v }
+ opt.on('', '--dry-run') { options[:dry_run] = true }
+ opt.on('-e', '--export') { mode = :export }
+ opt.on('-o', '--output FILE') {|v| output_file = v }
+ opt.on('', '--show-metrics') { mode = :show_metrics }
+ opt.on('', '--show-dimensions') { mode = :show_dimensions }
+ opt.on('', '--show-statistics') { mode = :show_statistics }
+ opt.on('', '--namespace NAMESPACE') {|v| show_opts[:namespace] = v }
+ opt.on('', '--metric-name NAME') {|v| show_opts[:metric_name] = v }
+ opt.on('', '--start-time TIME', Time) {|v| show_opts[:start_time] = v }
+ opt.on('', '--end-time TIME', Time) {|v| show_opts[:end_time] = v }
+ opt.on('', '--end-time TIME', Time) {|v| show_opts[:end_time] = v }
+ opt.on('' , '--statistic STATISTIC', Radiosonde::DSL::Statistic::ALIASES.values) {|v|
+ show_opts[:statistic]
+ }
+ opt.on('' , '--no-color') { options[:color] = false }
+ opt.on('' , '--debug') { options[:debug] = true }
opt.parse!
aws_opts = {}
if access_key and secret_key
@@ -95,9 +114,16 @@
logger.info(msg)
updated = client.apply(file)
logger.info('No change'.intense_blue) unless updated
+ when :show_metrics
+ puts JSON.pretty_generate(client.metrics(show_opts))
+ when :show_dimensions
+ puts JSON.pretty_generate(client.metrics(show_opts.merge(:with_dimensions => true)))
+ when :show_statistics
+ show_opts[:statistics] = [Radiosonde::DSL::Statistic.normalize(show_opts[:statistic])]
+ puts JSON.pretty_generate(client.metrics(show_opts.merge(:with_statistics => true)))
else
raise 'must not happen'
end
rescue => e
if options[:debug]