module Daemonz::ProcTable
Mocks the sys-proctable gem using ps.
This is useful even if sys-proctable is available, because it may fail for random reasons.
The accelerated version is not available, use the slow version all the time.
Public Class Methods
ps()
click to toggle source
# File lib/daemonz/process.rb, line 33 def self.ps # We don't use ps_emulation all the time because sys-proctable is # faster. We only pay the performance penalty when sys-proctable fails. begin Sys::ProcTable.ps rescue Exception self.ps_emulation end end
ps_emulation()
click to toggle source
# File lib/daemonz/process.rb, line 14 def self.ps_emulation retval = [] ps_output = `ps ax` ps_output.each_line do |pline| pdata = pline.split(nil, 5) pinfo = ProcInfo.new(pdata[0].strip, pdata[4].strip) retval << pinfo end return retval end