Intro
It’s a little hard to find this information on the Internet, so I’m amplifying the correct answer here by using my blog.
The details
I’m not super-competent with MIBs and such, but I manage for my purposes with my basic understanding. I have access to an F5 bigip with various IPSEC tunnels on it. I want to use Zabbix to check the status of those tunnels. So I do an SMPwalk like this:
snmpwalk -v3 … -c public 127.0.0.1 F5-BIGIP-SYSTEM-MIB::sysIpsecSpdStatTunnelState
which produces output like this line:
F5-BIGIP-SYSTEM-MIB::sysIpsecSpdStatTunnelState.”/Common/tunnel-01″.58401 = STRING: up
But I cannot take that as it is and use it in an snmpget like this:
snmpget -v3 … -c public 127.0.0.1 F5-BIGIP-SYSTEM-MIB::sysIpsecSpdStatTunnelState.”/Common/tunnel-01″.58401
That produces an error like this:
Unknown Object Identifier (Index out of range: /Common/tunnel-01 (sysIpsecSpdStatTrafficSelectorName))
So we need to convert the string into a numeric OID. But how?
The answer
Use the -On switch as an additional argument in your snmpwalk.
You will get a scary long OID, but it will at least be numeric.
Gonig further
You can then deconstruct the response and reconstitute the section at the beginning with a nice name. For my F5 example
.1.3.6.1.4.1.3375.2.1.2.17.1.3.1.14
becomes
F5-BIGIP-SYSTEM-MIB::sysIpsecSpdStatBytes
I think. Then preserve the following digits as is.
Conclusion
We have shown how to output a numeric OID from an snmpwalk. This, specifically, is sueful in converting a string embedded in the output into a numeric OID, which may then be used by other SNMP applications such as Zabbix which may or may not have the MIB file loaded. The secret is simply to use the -On switch in snmpwalk.
References and related
My Zabbix FAQ – questions you wish they had answered, can be very helpful