I am trying to write a piece of code that accepts a JSON object with OIDs as keys and OID values as values. An Example would be:
{".1.3.6.1.4.1.562.29.6.2.3": "Link Down",
...
}
When this JSON object is received I want to translate the OID and the OID value using PySNMP, but I do not know how I can translate the OID value according to Textual Conventions defined within a corresponding MIB file.
An example MIB file would define:
TruthValue ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"Represents a boolean value."
SYNTAX INTEGER { true(1), false(2) }
Given an OID and an OID value that follows a textual convention like the one above I would like to translate:
{"OID": 1,...}
into {"OID": true,...}
Is this possible with PySNMP?
That is possible with pysnmp:
However in general you would have to somehow map OIDs to value types (some of which may resolve into TEXTUAL-CONVENTIONS). This can be done in an ad-hoc manner by hardcoding OID->type mapping for specific OIDs in your app, but a more general solution is to employ pysnmp MIB services:
The above example would fetch value type for 1.3.6.1.6.3.10.2.1.1.0 and cast 12341234 value into associated type.
UPDATED:
Consider using the higher-level interface to MIB services which is available since pysnmp 4.3