A friend asked me how to go about doing this, and I figured I’d post it here so he can find it again if he needs it.
You’ve already discovered that snmp-server chassis-id is a user-maintained field and therefore not reliable , so you can skip trying to use chassisId (22.214.171.124.126.96.36.199.6.3) from OLD-CISCO-CHASSIS-MIB. It’s supposed to be depracated anyway.
Newer equipment supports the ENTITY-MIB. (For certain definitions of “support” … it’s not pretty.)
There are a number of ways to do this. The most straightforward, if you’re starting from scratch, is to walk entPhysicalClass and look for items of type 3, chassis.
It’ll look like this:
:::-->snmpwalk -v 2c -M ~/.snmp/mibs -m ENTITY-MIB -c public -O s myswitch entPhysicalClass | grep chassis
entPhysicalClass.1001 = INTEGER: chassis(3)
Then, use entPhysicalSerialNum and the iid you just found (the 1001 in the previous example) to find the serial number:
:::-->snmpget -v 2c -M ~/.snmp/mibs -m ENTITY-MIB -c public -O s myswitch entPhysicalSerialNum.1001
entPhysicalSerialNum.1001 = STRING: FOC14475A35
In case you don’t have those mibs installed & don’t want to bother with it, here are the numerical equivalents:
That method would look like this:
:::-->snmpwalk -v 2c -c public -O s myswitch .188.8.131.52.184.108.40.206.220.127.116.11 | grep "INTEGER: 3"
mib-18.104.22.168.22.214.171.1241 = INTEGER: 3
:::-->snmpget -v 2c -c public -O s myswitch .126.96.36.199.188.8.131.52.184.108.40.206.1001
mib-220.127.116.11.18.104.22.1681 = STRING: "FOC14475A35"
Now, if you want to get fancy and maybe find out the model number as well, you can then check any of the following (in order of how useful they’ve been to me personally):
…which would look like this:
:::-->snmpget -v 2c -M ~/.snmp/mibs -m ENTITY-MIB -c public -O s myswitch \
entPhysicalModelName.1001 = STRING: SM-ES3G-16-P
entPhysicalDescr.1001 = STRING: SM-ES3G-16-P
entPhysicalName.1001 = STRING: 1
1 – These things tend to migrate off the equipment they were originally configured on, on to other machines, via a copy & paste vector. Pretty soon you have five or six different boxes that supposedly have the same serial number.