Val:~$ whoami

I am Val Glinskiy, network engineer specializing in data center networks. TIME magazine selected me as Person of the Year in 2006.

Search This Blog

Monday, July 20, 2009

Need to find out Cisco switch serial number?

Yes, you can do it by logging in and running "show idprom backplane" or "show inventory". What if you have hundreds of switches and need to update your inventory list. Going to every switch, typing commands and writing down serial numbers is very time consuming. There is also Expect script, but I am not a big fan of putting clear text passwords into code. So, my favorite SNMP to the rescue.
Serial number OID for modular switches (4500 and 6500) is .1.3.6.1.2.1.47.1.1.1.1.11.1. For Catalyst 2960 and 3500: 1.3.6.1.2.1.47.1.1.1.1.11.1001

Here is the quick shell script to get serial number and location of each switch.

for i in `cat switches.txt`
do
serial=`snmpwalk -Ov -Oq -v2c -c public $i 1.3.6.1.2.1.47.1.1.1.1.11.1001`
location=`snmpwalk -Ov -Oq -v2c -c public $i system.sysLocation`
echo -e "$i \t $serial \t $location"
done

File switches.txt contains ip addresses of my access switches, one per line. It goes without saying that each switch must have "snmp-server location" configured.

No comments:

Post a Comment