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.



8
9
10
11
12
13
14
15
16
17
# File 'lib/moro/process.rb', line 8

def initialize(options)
  @name=options[:name]
  @file=options[:file]
  if options[:tags]!=nil
    @tags=options[:tags]
  else
    @tags=[]
  end
  update_pid
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#pidObject (readonly)

Returns the value of attribute pid.



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

def pid
  @pid
end

#tagsObject (readonly)

Returns the value of attribute tags.



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

def tags
  @tags
end

Instance Method Details

#usageObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/moro/process.rb', line 19

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,tags:tags}
  else
    update_pid
    {name:name,memory:0.0,tags:tags}
  end
end