Class: God::System::Process
- Inherits:
-
Object
- Object
- God::System::Process
- Defined in:
- lib/god/system/process.rb
Instance Method Summary collapse
-
#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 8 |
# File 'lib/god/system/process.rb', line 5 def initialize(pid) @pid = pid.to_i @poller = fetch_system_poller.new(@pid) end |
Instance Method Details
#exists? ⇒ Boolean
Return true if this process is running, false otherwise
11 12 13 |
# File 'lib/god/system/process.rb', line 11 def exists? !!::Process.kill(0, @pid) rescue false end |
#memory ⇒ Object
Memory usage in kilobytes (resident set size)
16 17 18 |
# File 'lib/god/system/process.rb', line 16 def memory @poller.memory end |
#percent_cpu ⇒ Object
Percentage CPU usage
26 27 28 |
# File 'lib/god/system/process.rb', line 26 def percent_cpu @poller.percent_cpu end |
#percent_memory ⇒ Object
Percentage memory usage
21 22 23 |
# File 'lib/god/system/process.rb', line 21 def percent_memory @poller.percent_memory end |