how make pysmp oids respone readable for human

231 Views Asked by At

I create some smnp agent which will be use pysnmp to get response with OID. How I can make response OID readable for human with pysnmp?

Example command generator:

    cmdGen = cmdgen.CommandGenerator()

    errorIndication, errorStatus, errorIndex, varBinds =cmdGen.getCmd(
    cmdgen.UsmUserData('user','privKey','authKey'),
    cmdgen.UdpTransportTarget(('127.0.0.1', 161)),(1,3,6,1,2,1,1,1,0))

    #what I need:
    make_human_readble_OID(VarBinds)

Thanks for help!

1

There are 1 best solutions below

0
On BEST ANSWER

You should pass the lookupNames and/or lookupValues flags to getCmd() as shown here. Keep in mind that human readability usually requires explicit use of MIBs. To use MIBs with pysnmp you would have to:

  1. Convert MIBs from their native ASN.1 representation into pysnmp classes using build-pysnmp-mib tool (from pysnmp distribution)
  2. Make pysnmp load and use those pysnmp-style MIBs by passing their location on the filesystems to MibVariable through .loadMibs() or .addMibSources() as shown here