jn123
jn123

Reputation: 11

pysnmp prettyPrint translates OID names

I am trying to get the MIB in raw format OID-value. With lookupNames = False, lookupValues = False I get what I want but when trying so get it in lets say CSV format:

(pname, pval) = (name.prettyPrint(), val.prettyPrint())

prettyPrint alters the values:

# name: 1.3.6.1.2.1.15.3.1.4.30.30.24.4

# pname: RFC1213-MIB::mib-2.15.3.1.4.30.30.24.4

is there any way to avoid this please and get just the full numerical OID ??

I have pysnmp (4.3.9).

Upvotes: 1

Views: 1880

Answers (1)

Ilya Etingof
Ilya Etingof

Reputation: 5555

I'd advise you to use the pysnmp hlapi API which takes a single lookupMib=False parameter and with pysnmp 4.3.9 it seems to produce pure OIDs.

Also, there is a way to get rid of SNMP types completely. You can call tuple() on the OID values so you get a tuple of integer sub-OIDs. Likewise, you could call int on numeric SNMP values and str on string SNMP values to get Python objects of built-in types. The catch is that you first have to figure out the SNMP type you deal with to do appropriate type casting.

Upvotes: 1

Related Questions