Class: Moro::Process

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Process

Returns a new instance of Process.



7
8
9
10
11
12
# File 'lib/moro/process.rb', line 7

def initialize(options)
  @logger = Logger.new STDOUT
  @name=options[:name]
  @file=options[:file]
  update_pid
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#pidObject (readonly)

Returns the value of attribute pid.



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

def pid
  @pid
end

Instance Method Details

#usageObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/moro/process.rb', line 14

def usage
  if pid!=nil
    pm=GetProcessMem.new(pid)
    #pid need to change
    if pm.bytes==0
      update_pid
    end
    pm=GetProcessMem.new(pid)
    mem = pm.mb
    {name:name,memory:mem}
  else
    update_pid
    {name:name,memory:0.0}
  end
end