Handbook: Processes

Get the list of processes on a box:

box.processes

This returns a ProcessSet which behaves like an array, but also lets you do bulk actions (like "kill") on the entire set.

In the shell, "processes" by itself is a shortcut to Rush::Box.new.processes.

Processes have fields uid, pid, command, cmdline, mem, and cpu. Use filter to reduce the set to the entries you want:

box.processes.filter(:pid => ::Process.pid)
box.processes.filter(:cmdline => /ssh/)

ProcessSet acts like an array, so get more complex with a standard select:

box.processes.select { |p| p.cmdline.match(/mongrel_rails/) and p.mem > 100_000 }

Check if the process is alive, or kill it:

ff = box.processes.filter(:cmdline => /firefox/) puts ff.alive?.inspect ff.kill

Next: Bash