SNMP stands for Simple Network Management Protocol and it is commonly used to access and manage network equipment such as switches and routers. It has been available for a long time and has evolved quite a lot with better functionality and security. Each SNMP object can be addressed by its Object IDs (OIDs) and I find that many new SNMP users are confused about the SNMP OIDs and how they should be used correctly. There are 3 major kinds of SNMP OIDs, scalar, table and dynamic and each has its own unique way of accessing. This blog will explain each type of OID and show how they can be accessed correctly.
SNMP Scalar Type OID
Scalar SNMP OID represents one single value that is available for GET/SET on a SNMP agent. This type of SNMP OID is represented by a ‘leaf icon’ (if read only) or a “paper and pen” icon (if read and write) on MIB browser.
To access a scalar value SNMP OID, you need to append a zero (0) in the end of the OID number.
cxSysBplTopologyTree has OID number = .22.214.171.124.4.1.6126.96.36.199.1
To access it, you much append a zero (0) in the end to indicate that you want to access this OID as a scalar value. So it becomes = .188.8.131.52.4.1.6184.108.40.206.1.0. without this zero, you will get “OID does not exist error”
SNMP Table Type OID
Table OID represents one or more sets of values that are available for GET/SET on a SNMP agent. This type of SNMP OID is represented by a ‘Table icon’ on MIB browser. Each Table OID must have an index value that can be used by the client to select which table entry to retrieve value from. The index value is represented by the “key” icon on MIB browser and normally it is defined as integer.
To access a value from a Table OID, you need to append an index number that is larger than zero at the end of the OID number
plSysFWVersion has OID = .220.127.116.11.4.1.618.104.22.168.1.5
To access it, you must append an index number in the end of the OID number to select one of many table entries. In most cases, (also our case), you need to put the index number = 1 to indicate you would like the value from table entry number 1. So the OID becomes .22.214.171.124.4.1.6126.96.36.199.1.5.1. Without this index number 1, you will get “OID does not exist error”.
Why do we need a table OID?
SNMP is mostly used to manage network equipment and it is common that this network equipment can have multiple Network Interface Card (NIC), for example (eth0, eth1, eth4…etc). If table is not used, you will need to define multiple separate sets of SNMP OIDS, each corresponding to one NIC. This is extremely not efficient and could get messy. Easier way is to define the table OIDs containing only one set of OID common for all NICs, and manager software can access each NIC’s OID values simply by varying the index number
Dynamic OID is a more advanced usage of Table OID, which involves using more than one value to index table entries. In table OID, we talked about using one integer value to select a table entry by appending a number in the end of OID value. In addition to the integer number acting as primary index, we can define a second index value to further refine the result… like a 2 dimensional table, and we call this dynamic OID. For dynamic OID, the table is defined like the picture below… with 2 keys defined to look up a table value:
plPhyByMACCard and plPhyByMACMAC
This means in order to retrieve a value from this table, you have to supply 2 key values
This is an integer value index, which we will append “1” in our case just like the previous chapter
This is the second index, and it has a type = PHYSADDRESS instead of integer, this means you need to append the 6 byte MAC address (in decimal form) also to the end of the OID in order to retrieve this value
• plPhyByMACTxPhySpeed has OID = .188.8.131.52.4.1.6184.108.40.206.1.1.11
We need to append a “1” in the end of the OID due to first index (plPhyByMACCard)
So it becomes .220.127.116.11.4.1.618.104.22.168.22.214.171.124
• Now we need to tell the agent which MAC address we would like to get the PHY speed from, let’s say MAC = 00:0B:C2:12:CD:E3. In our case, this MAC address is sent to the transport in cxSysPeerMacAddr attribute field
• We need to convert the MAC to 6 decimal numbers
So it becomes 0.11.194.18.205.227
• Now we append the six numbers at the end of the OID that has been appended 1 from previous step:
So it becomes .126.96.36.199.4.1.6188.8.131.52.184.108.40.206.0.11.194.18.205.227
Why do we need a second key value defined as MAC address?
Let’s say a network switch has 5 devices connected to it having 5 different MAC addresses and there is one dynamic table OID using Network ID and MAC as keys defined to record the PHY speed to each connected equipment. In order for a SNMP manager to read the speed to one MAC equipment, it has to supply both network id and MAC address as index to the SNMP table so the agent can return the speed for respective device. Without dynamic table OID, the client simply cannot retrieve the speed value for any of the devices. SNMP walk can be used to GET all the available table entries, which represent all the devices connected.
In the screenshot above, I first did a snmpwalk on OID .220.127.116.11.4.1.618.104.22.168.1.1.11 without any index added, then I receive 2 entries, each entry corresponding to the Tx speed of one MAC. As you can see, even the returned value has the OID + integer index + MAC index. Second, I did a snmpget on OID .22.214.171.124.4.1.6126.96.36.199.188.8.131.52.0.11.194.18.205.227 and I only get one entry in the result as I have selected.
Hi, this is Cary, your friendly tech enthusiast, educator and author. I enjoy simplifying complex concepts, diving into coding challenges, unraveling the mysteries of software and most importantly, sharing and teaching others about all things tech.