我正在使用PySNMP获取CDP邻居的IP。这是我当前使用的函数,它可以工作,但是输出的类型是hexValue。
def get_neighbors():
for (errorIndication,
errorStatus,
errorIndex,
values) in nextCmd(SnmpEngine(),
CommunityData('public', mpModel=0),
UdpTransportTarget((SWITCH, 161)),
ContextData(),
ObjectType(ObjectIdentity('CISCO-CDP-MIB', 'cdpCacheAddress')).addAsn1MibSource('file://asn1/CISCO-CDP-MIB'),
lexicographicMode=False, lookupNames=True, lookupValues=True):
print(values)
for v in values:
print(v)它输出以下内容:
[ObjectType(ObjectIdentity(ObjectName('1.3.6.1.4.1.9.9.23.1.2.1.1.4.10106.14')), CiscoNetworkAddress(hexValue='ac14103a'))]
CISCO-CDP-MIB::cdpCacheAddress.10106.14 = 0xac14103a
[ObjectType(ObjectIdentity(ObjectName('1.3.6.1.4.1.9.9.23.1.2.1.1.4.10125.9')), CiscoNetworkAddress(hexValue='ac1413fc'))]
CISCO-CDP-MIB::cdpCacheAddress.10125.9 = 0xac1413fc如何将0xac14103a转换为IP地址?或者是否有可能以某种方式获取CiscoNetworkAddress的值
https://stackoverflow.com/questions/41568992
复制相似问题