Class: Datacenter::Process

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#cacheObject (readonly)

Returns the value of attribute cache.



18
19
20
# File 'lib/datacenter/process.rb', line 18

def cache
  @cache
end

#machineObject (readonly)

Returns the value of attribute machine.



18
19
20
# File 'lib/datacenter/process.rb', line 18

def machine
  @machine
end

#pidObject (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

Returns:

  • (Boolean)


26
27
28
# File 'lib/datacenter/process.rb', line 26

def alive?
  !(machine.shell.run 'ls /proc').scan("\n#{pid}\n").empty?
end