Class: ITRP::Cmd_cglist

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

Returns a new instance of Cmd_cglist.



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

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

Instance Method Details

#enter(cmdline) ⇒ Object



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

def enter(cmdline)
	req =mk_request(TRP::Message::Command::COUNTER_GROUP_INFO_REQUEST, {:get_meter_info=>true} )

	rows = []
	get_response_zmq(@appenv.zmq_endpt,req) do |resp|
		  resp.group_details.each do |group_detail|
		  	cstr=""
		    if group_detail.crosskey 
				cstr = [group_detail.crosskey.parentguid, 
					    group_detail.crosskey.crosskeyguid_1,
					    group_detail.crosskey.crosskeyguid_2].join(",") 

			end 
		  	rows << [ group_detail.name,
					  group_detail.guid,
					  group_detail.bucket_size.to_i/1000,
					  group_detail.meters.size,
					  cstr
			        ]
		  end
	end

	table = Terminal::Table.new :headings => %w(name guid bs num_meters), :rows => rows
	puts(table) 
end