[tkined] VLAN mapping

Doug Hughes (Doug.Hughes@Eng.Auburn.EDU)
Tue, 16 Nov 1999 09:24:30 -0600 (CST)

For what it's worth, here's a little script I use to quickly dump out
the VLANS on all of our Cisco catalysts. Output looks like this:

port 1 Name VL1 Vlan LastChange: 0d 0:00:32.38 link: up
port 2 Name Fa0/1 Vlan 12 LastChange: 9d 19:56:25.26 link: up
port 3 Name Fa0/2 Vlan 12 LastChange: 0d 0:07:20.75 link: up
port 4 Name Fa0/3 Vlan 12 LastChange: 0d 0:07:28.90 link: up
port 5 Name Fa0/4 Vlan 12 LastChange: 9d 19:56:24.18 link: up
port 6 Name Fa0/5 Vlan 12 LastChange: 9d 19:56:24.18 link: up
port 7 Name Fa0/6 Vlan 12 LastChange: 9d 19:56:24.18 link: up
port 8 Name Fa0/7 Vlan 12 LastChange: 0d 0:09:13.96 link: up
port 9 Name Fa0/8 Vlan 12 LastChange: 6d 23:42:19.02 link: up
port 10 Name Fa0/9 Vlan 12 LastChange: 0d 0:05:51.35 link: down
port 11 Name Fa0/10 Vlan 10 LastChange: 0d 0:00:49.23 link: up
port 12 Name Fa0/11 Vlan 12 LastChange: 0d 0:09:00.80 link: down
...

Here's the script for anybody that wants to use it (I put it in my .scottyrc)

proc vlanmap {} {
global s
$s walk x ifName {
set oid [lindex [lindex $x 0] 0]
set pname [lindex [lindex $x 0] 2]
set osplit [split $oid .]
set port [lindex $osplit [expr [llength $osplit] -1]]
# puts "$port"
lappend ports [list $port $pname]
}

foreach port $ports {
if {[catch {set vlan [$s get vmVlan.[lindex $port 0]]}]} {
set vlan [list "??" "??"]
}
puts [format "port %4.4s Name %-6.6s Vlan %-3.3s Last Change: %-16s link: %s" \
[lindex $port 0] [lindex $port 1] [lindex [lindex $vlan 0] 2]\
[lindex [lindex [$s get ifLastChange.[lindex $port 0]] 0] 2] \
[lindex [lindex [$s get ifOperStatus.[lindex $port 0]] 0] 2]]
}
}

It assumes you've got your snmp session in a global variable named 's', though
it could be changed to anything.

Doug

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.