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.
13 14 15 16 |
# File 'lib/god/system/process.rb', line 13 def initialize(pid) @pid = pid.to_i @poller = self.class.fetch_system_poller.new(@pid) end |
Class Method Details
.fetch_system_poller ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/god/system/process.rb', line 5 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
19 20 21 |
# File 'lib/god/system/process.rb', line 19 def exists? !!::Process.kill(0, @pid) rescue false end |
#memory ⇒ Object
Memory usage in kilobytes (resident set size)
24 25 26 |
# File 'lib/god/system/process.rb', line 24 def memory @poller.memory end |
#percent_cpu ⇒ Object
Percentage CPU usage
34 35 36 |
# File 'lib/god/system/process.rb', line 34 def percent_cpu @poller.percent_cpu end |
#percent_memory ⇒ Object
Percentage memory usage
29 30 31 |
# File 'lib/god/system/process.rb', line 29 def percent_memory @poller.percent_memory end |