Class: Smith::Commands::Top
- Inherits:
-
Smith::CommandBase
- Object
- Smith::CommandBase
- Smith::Commands::Top
- Defined in:
- lib/smith/commands/smithctl/top.rb
Instance Attribute Summary
Attributes inherited from Smith::CommandBase
Instance Method Summary collapse
Methods inherited from Smith::CommandBase
#banner, #format_help, #initialize, #parse_options
Methods included from Logger
Constructor Details
This class inherits a constructor from Smith::CommandBase
Instance Method Details
#execute ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/smith/commands/smithctl/top.rb', line 8 def execute Curses.init_screen() win = Curses::Window.new(Curses.lines, Curses.cols, 0, 0) Messaging::Receiver.new(QueueDefinitions::Agent_stats) do |receiver| receiver.subscribe do |r| payload = r.payload win.setpos(0,0) win.addstr("%s %12s %5s %5s" % ["Queue", "Pid", "RSS", "Time"]) win.setpos(2,0) win.addstr(format(payload)) win.refresh end end end |
#format(payload) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/smith/commands/smithctl/top.rb', line 24 def format(payload) s = "" s << "%s %.12s %5s %5s\n\n" % [payload.agent_name, payload.pid, payload.rss, payload.up_time] s << payload.queues.map do |queue| " %-26s %d" % [queue.name, queue.length] end.join("\n") end |