Class: Wavefront::Cli::Ts
- Inherits:
-
Wavefront::Cli
- Object
- Wavefront::Cli
- Wavefront::Cli::Ts
- Includes:
- Mixins
- Defined in:
- lib/wavefront/cli/ts.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
-
#options ⇒ Object
Returns the value of attribute options.
Attributes inherited from Wavefront::Cli
Instance Method Summary collapse
Methods included from Mixins
#call_delete, #call_get, #call_post, #hash_to_qs, #interpolate_schema, #load_file, #parse_time, #time_to_ms, #uri_concat
Methods inherited from Wavefront::Cli
Constructor Details
This class inherits a constructor from Wavefront::Cli
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
24 25 26 |
# File 'lib/wavefront/cli/ts.rb', line 24 def arguments @arguments end |
#options ⇒ Object
Returns the value of attribute options.
24 25 26 |
# File 'lib/wavefront/cli/ts.rb', line 24 def @options end |
Instance Method Details
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/wavefront/cli/ts.rb', line 26 def run raise 'Please supply a query.' if @arguments.empty? query = @arguments[0] if @options[:minutes] granularity = 'm' elsif @options[:hours] granularity = 'h' elsif @options[:seconds] granularity = 's' elsif @options[:days] granularity = 'd' else raise "You must specify a granularity of either --seconds, --minutes --hours or --days. See --help for more information." end unless Wavefront::Client::FORMATS.include?(@options[:format].to_sym) raise "The output format must be one of: #{Wavefront::Client::FORMATS.join(', ')}." end = Hash.new [:response_format] = @options[:format].to_sym [:prefix_length] = @options[:prefixlength].to_i if @options[:start] [:start_time] = Time.at(parse_time(@options[:start])) end if @options[:end] [:end_time] = Time.at(parse_time(@options[:end])) end wave = Wavefront::Client.new(@options[:token], @options[:endpoint], @options[:debug], { noop: @options[:noop], verbose: @options[:verbose]}) if noop wave.query(query, granularity, ) return end case [:response_format] when :json pp wave.query(query, granularity, ) when :raw puts wave.query(query, granularity, ) when :graphite puts wave.query(query, granularity, ).graphite.to_json when :human puts wave.query(query, granularity, ).human else pp wave.query(query, granularity, ) end exit 0 end |