Class: Wildcloud::Agent::LoadMonitor
- Inherits:
-
Object
- Object
- Wildcloud::Agent::LoadMonitor
- Defined in:
- lib/wildcloud/agent/load_monitor.rb
Instance Method Summary collapse
-
#initialize(agent) ⇒ LoadMonitor
constructor
A new instance of LoadMonitor.
- #report ⇒ Object
- #system_configuration ⇒ Object
Constructor Details
#initialize(agent) ⇒ LoadMonitor
Returns a new instance of LoadMonitor.
21 22 23 24 25 26 27 |
# File 'lib/wildcloud/agent/load_monitor.rb', line 21 def initialize(agent) @sigar = Sigar.new @agent = agent @cpu_load = [:user, :sys, :nice, :idle, :wait, :irq, :soft_irq, :stolen, :total] @memory = [:total, :ram, :used, :free, :actual_used, :actual_free, :used_percent, :free_percent] @swap = [:total, :used, :free, :page_in, :page_out] end |
Instance Method Details
#report ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/wildcloud/agent/load_monitor.rb', line 32 def report report = { :memory => { :ram => {}, :swap => {} }, :cpu => { :avg => @sigar.loadavg, :detail => [] }, :uptime => @sigar.uptime.uptime } stats = @sigar.mem @memory.each do |info| report[:memory][:ram][info] = stats.send(info) end stats = @sigar.swap @swap.each do |info| report[:memory][:swap][info] = stats.send(info) end @sigar.cpu_list.each do |cpu| report[:cpu][:detail] << {} @cpu_load.each do |info| report[:cpu][:detail].last[info] = cpu.send(info) end end report end |
#system_configuration ⇒ Object
29 30 |
# File 'lib/wildcloud/agent/load_monitor.rb', line 29 def system_configuration end |