Sha256: f7d975984fb64c4fbbd1854d9308b9a44e0046a9e1a04c720b5e1838ce5b4a04
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
module Copian module Collector class BandwidthCollector < AbstractCollector # :nodoc: def initialize(manager) super(manager) @interfaces = Hash.new end def collect load_inoctets load_outoctets @interfaces.each do |ifindex, stats| yield ifindex, stats[:inoctets], stats[:outoctets] end end def collect64 load_inoctets64 load_outoctets64 @interfaces.each do |ifindex, stats| yield ifindex, stats[:inoctets64], stats[:outoctets64] end end protected def load_inoctets load_property(:inoctets, SNMP::ObjectId.new('1.3.6.1.2.1.2.2.1.10')) end def load_outoctets load_property(:outoctets, SNMP::ObjectId.new('1.3.6.1.2.1.2.2.1.16')) end def load_inoctets64 load_property(:inoctets64, SNMP::ObjectId.new('1.3.6.1.2.1.31.1.1.1.6')) end def load_outoctets64 load_property(:outoctets64, SNMP::ObjectId.new('1.3.6.1.2.1.31.1.1.1.10')) end def load_property(property, oid) @manager.walk(oid) do |r| r.each do |varbind| append_property(varbind.name.index(oid), property, varbind.value.to_i) end end end def append_property(index, property, value) @interfaces[index.to_s.to_i] ||= Hash.new @interfaces[index.to_s.to_i][property] = value end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
copian-1.3.3 | lib/copian/collector/bandwidth_collector.rb |
copian-1.3.2 | lib/copian/collector/bandwidth_collector.rb |