Class: ITRP::Cmd_metrics_summary

Inherits:
Cmd
  • Object
show all
Defined in:
lib/handlers/metric_summ.rb

Instance Attribute Summary

Attributes inherited from Cmd

#attach_cmd, #children, #enabled_in_state, #trigger

Instance Method Summary collapse

Methods inherited from Cmd

#appstate, #completions, #find_node, #is_root?, #place_node, #print_state, #set_time_window, #treeprint

Constructor Details

#initialize(e) ⇒ Cmd_metrics_summary

Returns a new instance of Cmd_metrics_summary.



4
5
6
7
8
9
# File 'lib/handlers/metric_summ.rb', line 4

def initialize (e)
  super(e)
  @enabled_in_state = :any
  @attach_cmd  = ''
  @trigger = 'metricsum'
end

Instance Method Details

#enter(cmdline) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/handlers/metric_summ.rb', line 11

def enter(cmdline)

    terms = cmdline.scan( /(\w+)\s*=\s*([\w\-_\.\:,\}\{]+)+/ )
    qparams = terms.inject({}) { |acc,t| acc.store( t[0].to_sym, t[1]);acc}


    p qparams 

    req =mk_request(TRP::Message::Command::METRICS_SUMMARY_REQUEST,
      #{:time_interval =>  appstate( :time_interval) }.merge(qparams) ) 
      {}.merge(qparams) ) 


    rows = []
    get_response_zmq(@appenv.zmq_endpt,req) do |resp|
      resp.vals.each do |val|
rows << [Time.at(val.ts.tv_sec) , val.val ]
      end
    end 

table = Terminal::Table.new(:headings => %w(Time Metric) ,  :rows => rows )
puts(table) 

end