Class: God::System::Process
- Inherits:
-
Object
- Object
- God::System::Process
- Defined in:
- lib/god/system/process.rb
Class Method Summary collapse
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.
14 15 16 17 |
# File 'lib/god/system/process.rb', line 14 def initialize(pid) @pid = pid.to_i @poller = self.class.fetch_system_poller.new(@pid) end |
Class Method Details
.fetch_system_poller ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/god/system/process.rb', line 6 def self.fetch_system_poller @@poller ||= if SlashProcPoller.usable? SlashProcPoller else PortablePoller end end |
Instance Method Details
#exists? ⇒ Boolean
Return true if this process is running, false otherwise
20 21 22 |
# File 'lib/god/system/process.rb', line 20 def exists? !!::Process.kill(0, @pid) rescue false end |
#memory ⇒ Object
Memory usage in kilobytes (resident set size)
25 26 27 |
# File 'lib/god/system/process.rb', line 25 def memory @poller.memory end |
#percent_cpu ⇒ Object
Percentage CPU usage
35 36 37 |
# File 'lib/god/system/process.rb', line 35 def percent_cpu @poller.percent_cpu end |
#percent_memory ⇒ Object
Percentage memory usage
30 31 32 |
# File 'lib/god/system/process.rb', line 30 def percent_memory @poller.percent_memory end |