[英]SNMP library for python failed return SNMP details
無法使用發布在 ( https://snmplabs.thola.io/pysnmp/quick-start.html ) 的示例獲取獲取 SNMP 變量詳細信息,並收到錯誤響應。 請建議如何修復錯誤。 提前致謝
Traceback (most recent call last):
File "d:/WorkFiles/SNMPTest/SNMP.py", line 6, in <module>
UdpTransportTarget(('snmpsim.try.thola.io', 161)),
File "D:\Python37\lib\site-packages\pysnmp\hlapi\transport.py", line 19, in __init__
self.transportAddr = self._resolveAddr(transportAddr)
File "D:\Python37\lib\site-packages\pysnmp\hlapi\asyncore\transport.py", line 63, in _resolveAddr
'@'.join([str(x) for x in transportAddr]), sys.exc_info()[1]))
pysnmp.error.PySnmpError: Bad IPv4/UDP transport address snmpsim.try.thola.io@161: [Errno 11001] getaddrinfo failedcaused by <class 'socket.gaierror'>: [Errno 11001] getaddrinfo failed
**
**
from pysnmp.hlapi import *
errorIndication, errorStatus, errorIndex, varBinds = next(
getCmd(SnmpEngine(),
CommunityData('public', mpModel=0),
UdpTransportTarget(('snmpsim.try.thola.io', 161)),
ContextData(),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)))
)
if errorIndication:
print(errorIndication)
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for varBind in varBinds:
print(' = '.join([x.prettyPrint() for x in varBind]))
如此處所述,我的公司正試圖接管PySNMP生態系統。
因此,您可以使用demo.pysnmp.com
來測試典型的 SNMP 命令/操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.