Class: Datacenter::Process
- Inherits:
-
Object
- Object
- Datacenter::Process
- Defined in:
- lib/datacenter/process.rb
Constant Summary collapse
- ATTRIBUTES =
[ :command, :status, :memory, :virtual_memory, :cpu, :user, :name, :cpu_usage, :mem_usage ]
- TIME_CACHE =
2
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(pid, machine = nil) ⇒ Process
constructor
A new instance of Process.
Constructor Details
#initialize(pid, machine = nil) ⇒ Process
Returns a new instance of Process.
20 21 22 23 24 |
# File 'lib/datacenter/process.rb', line 20 def initialize(pid, machine=nil) @pid = pid @machine = machine @cache = {:fetched=>0, :content=>[]} end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
18 19 20 |
# File 'lib/datacenter/process.rb', line 18 def cache @cache end |
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
18 19 20 |
# File 'lib/datacenter/process.rb', line 18 def machine @machine end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
18 19 20 |
# File 'lib/datacenter/process.rb', line 18 def pid @pid end |
Instance Method Details
#alive? ⇒ Boolean
26 27 28 |
# File 'lib/datacenter/process.rb', line 26 def alive? !(machine.shell.run 'ls /proc').scan("\n#{pid}\n").empty? end |