A special syntax for item OID can be used in order to deal with dynamic data (random IDs of network interfaces, etc). The syntax:
<base OID of data>["index","<base OID of index>","<string to search for>"]
For example, to get the ifInOctets value for the GigabitEthernet0/1 interface on a Cisco device, use the following OID:
ifInOctets["index","ifDescr","GigabitEthernet0/1"]
| Parameter | Description |
|---|---|
| base OID of data | Base OID to use for data retrieval. |
| index | Method of processing. Currently one method is supported index – search for index and append it to the base OID |
| base OID of index | The OID will be used to make a lookup for the string. |
| string to search for | The string is used for exact match with a value when doing lookup. Case sentitive. |
Another example, getting memory usage of apache process:
HOST-RESOURCES-MIB::hrSWRunPerfMem["index","HOST-RESOURCES-MIB::hrSWRunPath", "/usr/sbin/apache2"] ... HOST-RESOURCES-MIB::hrSWRunPath.5376 = STRING: "/sbin/getty" HOST-RESOURCES-MIB::hrSWRunPath.5377 = STRING: "/sbin/getty" HOST-RESOURCES-MIB::hrSWRunPath.5388 = STRING: "/usr/sbin/apache2" HOST-RESOURCES-MIB::hrSWRunPath.5389 = STRING: "/sbin/sshd" ...
Now we have index, 5388. The index will be appended to the Data OID in order to receive value we are interested in:
HOST-RESOURCES-MIB::hrSWRunPerfMem.5376 = INTEGER: 528 KBytes HOST-RESOURCES-MIB::hrSWRunPerfMem.5377 = INTEGER: 528 KBytes HOST-RESOURCES-MIB::hrSWRunPerfMem.5388 = INTEGER: 31468 KBytes HOST-RESOURCES-MIB::hrSWRunPerfMem.5389 = INTEGER: 31740 KBytes HOST-RESOURCES-MIB::hrSWRunPerfMem.5390 = INTEGER: 32116 KBytes HOST-RESOURCES-MIB::hrSWRunPerfMem.5391 = INTEGER: 30420 KBytes HOST-RESOURCES-MIB::hrSWRunPerfMem.5392 = INTEGER: 32560 Kbytes