Class: ITRP::Cmd_volume

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

Returns a new instance of Cmd_volume.



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

def initialize (e)
	super(e)
	@enabled_in_state = :counter
	@attach_cmd  = ''
	@trigger = 'volume'
end

Instance Method Details

#enter(cmdline) ⇒ Object



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
# File 'lib/handlers/volume.rb', line 13

def enter(cmdline)

	#volume TOTALBW [0]
       patt = cmdline.scan(/volume\s+(\S+)\s*(\d*)/).flatten


	use_key = patt.empty? ? appstate(:cgkey)  : patt[0]
	use_meter = patt[1].to_i  || 0 
       if use_key=="SYS:GROUP_TOTALS"
         use_key=TRP::KeyT.new({key:"SYS:GROUP_TOTALS"})
       end

	req =TrisulRP::Protocol.mk_request(TRP::Message::Command::COUNTER_ITEM_REQUEST,
		 :counter_group => @appenv.context_data[:cgguid],
		 :key => use_key, 
		 :volumes_only => 1,
		 :get_percentile => 0,
		 :time_interval =>  appstate( :time_interval) ) 

	rows  = [] 


	print "Request sent at  #{Time.now}\n"

	TrisulRP::Protocol.get_response_zmq(@appenv.zmq_endpt,req) do |resp|

		total = resp.totals.values[use_meter]
		pct = 0
		if resp.percentiles
			pct   = resp.percentiles.values[use_meter]
		end 

		print( "Total       = #{total * 60 }\n")
		print( "Percentile  = #{pct }\n")

	end

end