Class: WarCorrespondent::Reporters::Memory

Inherits:
WarCorrespondent::Reporter show all
Defined in:
lib/warcorrespondent/reporters/memory.rb

Instance Attribute Summary

Attributes inherited from WarCorrespondent::Reporter

#identifier, #options, #timeout

Instance Method Summary collapse

Methods inherited from WarCorrespondent::Reporter

#run, #update

Constructor Details

#initialize(args) ⇒ Memory

Returns a new instance of Memory.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/warcorrespondent/reporters/memory.rb', line 4

def initialize(args)
  @block = Proc.new do
    mem_items = {:free => :free, :cached => :cached, :buffers => :buffers, :total => :total, :used => :used}
    swap_items = {:swaptotal => :total, :swapfree => :free, :swapused => :used}
    memory = SystemInformation::memory
    mem_items = mem_items.map{|k,v| {:identifier => "mem:#{v.to_s}", :value => memory[k]}}
    swap_items = swap_items.map{|k,v| {:identifier => "swap:#{v.to_s}", :value => memory[k]}}
    mem_items + swap_items
  end
  super(args)
end