Class: Copian::Collector::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/copian/collector/generic.rb

Direct Known Subclasses

Cisco, Dell, Hp

Instance Method Summary collapse

Constructor Details

#initialize(ip_addr, community, version = :SNMPv2c) ⇒ Generic

Returns a new instance of Generic.



7
8
9
10
# File 'lib/copian/collector/generic.rb', line 7

def initialize(ip_addr, community, version = :SNMPv2c)
  @manager = SNMP::Manager.new(:host => ip_addr,
    :community => community, :version => version)
end

Instance Method Details

#bandwidth(options = {}) ⇒ Object

Collect bandwidth statistics

Arguments:

+options+

Valid Options

+:b64+  :Set to true to enable b64 bandwidth collection. Default false.


26
27
28
29
30
31
32
33
# File 'lib/copian/collector/generic.rb', line 26

def bandwidth(options = {}) # :yields: ifindex, ifname, inoctets, outoctets
  load_ifnames

  collect_method = options[:b64] == true ? :collect64 : :collect
  bandwidth_collector.send(collect_method) do |ifindex, inoctets, outoctets|
    yield ifindex, @ifnames[ifindex], inoctets, outoctets
  end
end

#descriptionsObject

:yields: ifindex, ifname, ifdescr



35
36
37
38
39
40
41
# File 'lib/copian/collector/generic.rb', line 35

def descriptions # :yields: ifindex, ifname, ifdescr
  load_ifnames

  description_collector.collect do |ifindex, ifdescr|
    yield ifindex, @ifnames[ifindex], ifdescr
  end
end

#inspectObject



4
5
6
# File 'lib/copian/collector/generic.rb', line 4

def inspect
  "#<#{self.class} #{@manager.host}@#{@manager.community}>"
end

#port_statsObject

:yields: ifindex, name, mtu, speed, admin_status, oper_status



11
12
13
14
15
16
17
# File 'lib/copian/collector/generic.rb', line 11

def port_stats # :yields: ifindex, name, mtu, speed, admin_status, oper_status
  load_ifnames

  port_stats_collector.collect do |ifindex, mtu, speed, admin_status, oper_status|
    yield ifindex, @ifnames[ifindex], mtu, speed, admin_status, oper_status
  end
end