Class: ITRP::Cmd_flow_trackers

Inherits:
Cmd
  • Object
show all
Defined in:
lib/handlers/trackers.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_flow_trackers

Returns a new instance of Cmd_flow_trackers.



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

def initialize (e)
	super(e)
	@enabled_in_state = :flow
	@attach_cmd  = ''
	@trigger = 'tracker'
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/handlers/trackers.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 =TrisulRP::Protocol.mk_request(TRP::Message::Command::SESSION_TRACKER_REQUEST,
		 qparams.merge(
		 :session_group  => appstate(:cgguid),
		 :time_interval => appstate(:time_interval),
		 :resolve_keys => true))

	rows = []
	TrisulRP::Protocol.get_response_zmq(@appenv.zmq_endpt,req) do |resp|
	
		resp.sessions.each do | sess |

		rows << [ "#{sess.session_key}",
				  Time.at( sess.time_interval.from.tv_sec).to_s(),
				  sess.probe_id,
				  sess.protocol.label,
				  sess.key1A.label,
				  sess.key1Z.label,
				  sess.key2A.label,
				  sess.key2Z.label,
				  sess.nf_routerid.nil? ? "": sess.nf_router_id.label,
				  sess.nf_ifindex_in.nil? ? "": sess.nf_ifindex_in.label,
				  sess.nf_ifindex_out.nil? ? "": sess.nf_ifindex_out.label,
				  sess.tracker_statval 
				]
		end

	end

	table = Terminal::Table.new( 
			:headings => %w(Key Last-Seen ProbeID Prot SourceIP DestIP SPort DPort Rtr IfIn IfOut TrackerVal),
			:rows => rows)
	puts(table) 


end