9 # Return true if this process is running, false otherwise
11 !ps_string('command').empty?
14 # Memory usage in kilobytes (resident set size)
19 # Percentage memory usage
24 # Percentage CPU usage
29 # Seconds of CPU time (accumulated cpu time, user + system)
31 time_string_to_seconds(ps_string('time'))
37 `ps -o #{keyword}= -p #{@pid}`.to_i
41 `ps -o #{keyword}= -p #{@pid}`.to_f
44 def ps_string(keyword)
45 `ps -o #{keyword}= -p #{@pid}`.strip
48 def time_string_to_seconds(text)
49 _, minutes, seconds, useconds = *text.match(/(\d+):(\d{2}).(\d{2})/)
50 (minutes.to_i * 60) + seconds.to_i