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 .220.127.116.11.18.104.22.168.22.214.171.124.1. For Catalyst 2960 and 3500: 126.96.36.199.188.8.131.52.184.108.40.206.1001
Here is the quick shell script to get serial number and location of each switch.
for i in `cat switches.txt`
serial=`snmpwalk -Ov -Oq -v2c -c public $i 220.127.116.11.18.104.22.168.22.214.171.124.1001`
location=`snmpwalk -Ov -Oq -v2c -c public $i system.sysLocation`
echo -e "$i \t $serial \t $location"
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.
Post a Comment