Class: Cloudscale::Plugins::SigarSwapUsage

Inherits:
Plugin
  • Object
show all
Defined in:
lib/cloudscale/plugins/os/sigar_swap_usage.rb

Instance Attribute Summary

Attributes inherited from Plugin

#log, #plugins, #rest_client

Instance Method Summary collapse

Methods inherited from Plugin

inherited, plugins, remove, remove_agenInstance, reset, resetRestEndpoint

Constructor Details

#initializeSigarSwapUsage

Returns a new instance of SigarSwapUsage.



17
18
19
20
21
22
# File 'lib/cloudscale/plugins/os/sigar_swap_usage.rb', line 17

def initialize
  super
  if is_enabled
    @sigar = Plugins::PluginPreop.instance.sigar
  end
end

Instance Method Details

#collect(agentInstanceId) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cloudscale/plugins/os/sigar_swap_usage.rb', line 24

def collect(agentInstanceId)
  registry = Monitor::Registry.instance
  metrics = Metrics::Agent.new
  log.info("Calling Collect on SigarSwapUsage")
  swap = @sigar.swap
  begin
    registry.metrics["os.swap.total"] = metrics.gauge :swap_total do
      { :value => swap.total }
    end
    registry.metrics["os.swap.used"] = metrics.gauge :swap_used do
      { :value => swap.used }
    end
    registry.metrics["os.swap.free"] = metrics.gauge :swap_free do
      { :value => swap.free }
    end
  rescue Exception => e
    puts e
  end
end

#is_enabledObject



13
14
15
# File 'lib/cloudscale/plugins/os/sigar_swap_usage.rb', line 13

def is_enabled
  true
end