Class: SNMPwalk
- Inherits:
-
Object
- Object
- SNMPwalk
- Defined in:
- lib/sflow/lib/sflow/snmp/iface_names.rb
Instance Attribute Summary collapse
-
#switchport ⇒ Object
Returns the value of attribute switchport.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(switchips) ⇒ SNMPwalk
constructor
A new instance of SNMPwalk.
Constructor Details
#initialize(switchips) ⇒ SNMPwalk
Returns a new instance of SNMPwalk.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sflow/lib/sflow/snmp/iface_names.rb', line 4 def initialize(switchips) print "Getting switch interface names " @switchport = {} switchips.each do |switchip| switch = Resolv.new.getname(switchip).split(/\./)[0] ports = {} snmpoutput = `snmpwalk -v2c -c public #{switchip} 1.3.6.1.2.1.2.2.1.2` snmpoutput.each_line do |line| split = line.split(/\s/) port = split[0].split(/\./).last if split[3] =~ /GigabitEthernet/ portname = split[3].scan(/\d+/).join('/') else portname = split[3] end hashp = { port => portname } ports.merge!(hashp) end hashs = { switch => ports } @switchport.merge!(hashs) print "." end puts " done." @switchport end |
Instance Attribute Details
#switchport ⇒ Object
Returns the value of attribute switchport.
3 4 5 |
# File 'lib/sflow/lib/sflow/snmp/iface_names.rb', line 3 def switchport @switchport end |
Class Method Details
.mapswitchportname(agent_address, iface) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/sflow/lib/sflow/snmp/iface_names.rb', line 32 def self.mapswitchportname(agent_address,iface) if $switchportnames.switchport["#{agent_address}"]["#{iface}"] $switchportnames.switchport["#{agent_address}"]["#{iface}"] else agent_address end end |