9 # Return true if this process is running, false otherwise
11 system("kill -0 #{@pid} &> /dev/null")
15 system("kill -9 `cat #{@pid}`")
18 # Memory usage in kilobytes (resident set size)
23 # Percentage memory usage
28 # Percentage CPU usage
33 # Seconds of CPU time (accumulated cpu time, user + system)
35 time_string_to_seconds(ps_string('time'))
41 `ps -o #{keyword}= -p #{@pid}`.to_i
45 `ps -o #{keyword}= -p #{@pid}`.to_f
48 def ps_string(keyword)
49 `ps -o #{keyword}= -p #{@pid}`.strip
52 def time_string_to_seconds(text)
53 _, minutes, seconds, useconds = *text.match(/(\d+):(\d{2}).(\d{2})/)
54 (minutes.to_i * 60) + seconds.to_i