Class: God::System::Process
- Inherits:
-
Object
- Object
- God::System::Process
- Defined in:
- lib/god/system/process.rb
Instance Method Summary collapse
-
#cpu_time ⇒ Object
Seconds of CPU time (accumulated cpu time, user + system).
-
#exists? ⇒ Boolean
Return true if this process is running, false otherwise.
-
#initialize(pid) ⇒ Process
constructor
A new instance of Process.
-
#memory ⇒ Object
Memory usage in kilobytes (resident set size).
-
#percent_cpu ⇒ Object
Percentage CPU usage.
-
#percent_memory ⇒ Object
Percentage memory usage.
Constructor Details
#initialize(pid) ⇒ Process
Returns a new instance of Process.
5 6 7 |
# File 'lib/god/system/process.rb', line 5 def initialize(pid) @pid = pid.to_i end |
Instance Method Details
#cpu_time ⇒ Object
Seconds of CPU time (accumulated cpu time, user + system)
30 31 32 |
# File 'lib/god/system/process.rb', line 30 def cpu_time time_string_to_seconds(ps_string('time')) end |
#exists? ⇒ Boolean
Return true if this process is running, false otherwise
10 11 12 |
# File 'lib/god/system/process.rb', line 10 def exists? system("kill -0 #{@pid} &> /dev/null") end |
#memory ⇒ Object
Memory usage in kilobytes (resident set size)
15 16 17 |
# File 'lib/god/system/process.rb', line 15 def memory ps_int('rss') end |
#percent_cpu ⇒ Object
Percentage CPU usage
25 26 27 |
# File 'lib/god/system/process.rb', line 25 def percent_cpu ps_float('%cpu') end |
#percent_memory ⇒ Object
Percentage memory usage
20 21 22 |
# File 'lib/god/system/process.rb', line 20 def percent_memory ps_float('%mem') end |