Class: ITRP::Cmd_query_flow
Instance Attribute Summary
Attributes inherited from Cmd
#attach_cmd, #children, #enabled_in_state, #trigger
Instance Method Summary collapse
- #completions(patt) ⇒ Object
- #enter(patt) ⇒ Object
-
#initialize(e) ⇒ Cmd_query_flow
constructor
A new instance of Cmd_query_flow.
Methods inherited from Cmd
#appstate, #find_node, #is_root?, #place_node, #print_state, #set_time_window, #treeprint
Constructor Details
#initialize(e) ⇒ Cmd_query_flow
Returns a new instance of Cmd_query_flow.
4 5 6 7 8 9 |
# File 'lib/handlers/query_flow.rb', line 4 def initialize (e) super(e) @enabled_in_state = :flow @attach_cmd = '' @trigger = 'query' end |
Instance Method Details
#completions(patt) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/handlers/query_flow.rb', line 11 def completions(patt) TRP::QuerySessionsRequest .fields .collect { |a| a.name.to_s } .grep( /^#{Regexp.escape(patt)}/i) end |
#enter(patt) ⇒ Object
18 19 20 21 22 23 24 25 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 |
# File 'lib/handlers/query_flow.rb', line 18 def enter(patt) terms = patt.scan( /(\w+)\s*=\s*([\w\-_\.\:,]+)+/ ) qparams = terms.inject({}) { |acc,t| acc.store( t[0].to_sym, t[1]);acc} p qparams # meter names req =mk_request(TRP::Message::Command::QUERY_SESSIONS_REQUEST , { :session_group => appstate(:cgguid), :time_interval => appstate(:time_interval), :resolve_keys => true, }.merge(qparams)) rows = [] get_response_zmq(@appenv.zmq_endpt,req) do |resp| resp.sessions.each_with_index do | sess , i | rows << [ i, "#{sess.session_id}", Time.at( sess.time_interval.from.tv_sec).to_s(), sess.time_interval.to.tv_sec - sess.time_interval.from.tv_sec, sess.probe_id, sess.protocol.label, sess.key1A.label, sess.key1Z.label, sess.key2A.readable, sess.key2Z.readable, sess.az_bytes + sess.za_bytes ] end end table = Terminal::Table.new( :headings => %w(num ID Time Dur Prb Prot SourceIP DestIP SPort DPort rtr IFin out Volume), :rows => rows) puts(table) end |