1

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]))
  • snmpsim.try.thola.io does not resolve to anything –  May 18 '22 at 11:25
  • @RichardDodson sorry don't understand your comment "snmpsim.try.thola.io does not resolve to anything " . could you please provide more details . i am looking for solution how to test SNMP sample code with valid SNMP agent. – HARIBABU KOMMALAPATI May 18 '22 at 14:59
  • I mean that using DNS, snmpsim.try.thola.io does not resolve to anything. That's why you're getting the error. –  May 18 '22 at 15:02
  • If you change `snmpsim.try.thola.io` to a an IP address or a hostname that's running SNMPv2 and configured with a community of `public`, it should work. –  May 18 '22 at 15:04
  • @RichardDodson Thanks for reply. I tried to get IPaddress for snmpsim.try.thola.io using ping cmd. but i did not get IP address from the domain. do you have any idea that is there any free SNMP responder domain to test SNMP ? – HARIBABU KOMMALAPATI May 18 '22 at 15:43
  • I'm sorry, but I don't know of any available SNMP servers. –  May 18 '22 at 15:46
  • Thanks . i have watched many youtube videos that they are using snmpsim.try.thola.io or demo.snmplabs.com and they able to get response. not sure why i am not getting – HARIBABU KOMMALAPATI May 18 '22 at 15:48
  • I think those videos must be old. I have never heard of snmpsim.try.thola.io, but snmplabs.com is no longer owned by whoever managed pysnmp when it was active. –  May 18 '22 at 15:57
  • Thanks @RichardDodson. I managed find SNMP service in my organization and able get variables. want to check where we can watch SNMP trap logs in windows machine. Because when i run my SNMP trap script i am getting empty results. is it expected ? – HARIBABU KOMMALAPATI May 19 '22 at 08:06
  • SNMP TRAP operations are completely different from others (like GET/SET), so if you meet any issue there, then you should post a new question and share the contents of your TRAP command/operation. – Lex Li Nov 30 '22 at 21:26

1 Answers1

0

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.

Lex Li
  • 60,503
  • 9
  • 116
  • 147