I am writing Python code in which a user inputs a SNMP OID in any of the following forms:
1.3.6.1.2.1.90.1.2
internet.2.1.90.1.2
I want my code to resolve internet
to 1.3.6.1
.
I was thinking of creating a dictionary and giving the corresponding values to the object names but I don't think that's a good idea.
Please help me in guiding how should I proceed.
NetSnmp provides a snmptranslate
method - that may be useful starting point.
Its man page says its purpose is to:
translate MIB OID names between numeric and textual forms.
There are already Python bindings for net-snmp
available, see these SO questions.
Alternatively pysnmp provides similar. See SO question "Translating pysnmp numerical oid output into symbolic names".