Frage

I'm retrieving a hex-string format IP address of CDP neighboor from the router using NET-SNMP. However, I get instead something weird thing. Any help? Thank you

War es hilfreich?

Lösung

As alecxe mentioned, you really need to provide more details when asking questions. Fortunately, I've used the NET-SNMP bindings for Python and already know what you are talking about.

To convert the binary data you receive from the NET-SNMP bindings to a hex representation, use the Python binascii module. The b2a_hex function is what you are looking for.

The following is mostly from memory, so it may not be exactly correct, but probably close enough to give you an idea.

import netsnmp
import binascii

session = netsnmp.Session(Community='public', DestHost='myagentip', Version=1)
vbwithbinarydata = netsnmp.VarBind('oid_to_binary_data')
varlist = netsnmp.Varlist(vbwithbinarydata)
session.get(varlist)
print binascii.b2a_hex(vbwithbinarydata.val)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top