简体   繁体   中英

SNMP library for python failed return SNMP details

Unable to get Fetch SNMP variable details using sample posted at ( https://snmplabs.thola.io/pysnmp/quick-start.html ) and got error response. please advice how to fix the error. Thanks in advance

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 

**

  • Code used for testing

**

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]))

My company is trying to take over PySNMP ecosystem, as documented here .

So, you can use demo.pysnmp.com to test out typical SNMP commands/operations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM