Class: Cloudscale::Plugins::SigarNetPacketInformation

Inherits:
Plugin
  • Object
show all
Defined in:
lib/cloudscale/plugins/os/sigar_packet_information.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, remove_measurements, reset, resetRestEndpoint

Constructor Details

#initializeSigarNetPacketInformation

Returns a new instance of SigarNetPacketInformation.



17
18
19
20
21
22
# File 'lib/cloudscale/plugins/os/sigar_packet_information.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/cloudscale/plugins/os/sigar_packet_information.rb', line 24

def collect(agentInstanceId)
  registry = Monitor::Registry.instance
  metrics = Metrics::Agent.new
  log.info("Calling Collect on SigarNetPacketInformation")
  iflist = @sigar.net_interface_list

  iflist.each do |ifname|
    if (!ifname.include?(":"))
      ifstat = @sigar.net_interface_stat(ifname)
      begin
        registry.metrics[("os.network.received.packets." + ifname).to_s] = metrics.gauge ("packets_received_" + ifname).to_sym do
          { :value => ifstat.rx_packets }
        end
        registry.metrics[("os.network.received.errors.packets." + ifname).to_s] = metrics.gauge ("packets_errors_received_" + ifname).to_sym do
          { :value => ifstat.rx_errors }
        end
        registry.metrics[("os.network.received.dropped.packets." + ifname).to_s] = metrics.gauge ("packets_dropped_received_" + ifname).to_sym do
          { :value => ifstat.rx_dropped }
        end

        registry.metrics[("os.network.send.packets." + ifname).to_s] = metrics.gauge ("packets_send_" + ifname).to_sym do
          { :value => ifstat.tx_packets }
        end
        registry.metrics[("os.network.send.errors.packets." + ifname).to_s] = metrics.gauge ("packets_errors_send_" + ifname).to_sym do
          { :value => ifstat.tx_errors }
        end
        registry.metrics[("os.network.send.dropped.packets." + ifname).to_s] = metrics.gauge ("packets_dropped_send_" + ifname).to_sym do
          { :value => ifstat.tx_dropped }
        end

      rescue Exception => e
        puts e
      end
    end
  end
end

#is_enabledObject



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

def is_enabled
  true
end