Class: God::System::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/god/system/process.rb

Instance Method Summary collapse

Constructor Details

#initialize(pid) ⇒ Process

Returns a new instance of Process.



5
6
7
# File 'lib/god/system/process.rb', line 5

def initialize(pid)
  @pid = pid.to_i
end

Instance Method Details

#cpu_timeObject

Seconds of CPU time (accumulated cpu time, user + system)



30
31
32
# File 'lib/god/system/process.rb', line 30

def cpu_time
  time_string_to_seconds(ps_string('time'))
end

#exists?Boolean

Return true if this process is running, false otherwise

Returns:

  • (Boolean)


10
11
12
# File 'lib/god/system/process.rb', line 10

def exists?
  system("kill -0 #{@pid} &> /dev/null")
end

#memoryObject

Memory usage in kilobytes (resident set size)



15
16
17
# File 'lib/god/system/process.rb', line 15

def memory
  ps_int('rss')
end

#percent_cpuObject

Percentage CPU usage



25
26
27
# File 'lib/god/system/process.rb', line 25

def percent_cpu
  ps_float('%cpu')
end

#percent_memoryObject

Percentage memory usage



20
21
22
# File 'lib/god/system/process.rb', line 20

def percent_memory
  ps_float('%mem')
end