Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple pysnmp example?
#1
I'm running python 3.13. I have v 7.1.17 of the pysnmp module installed.

I'm trying to do a simple SNMP get, but I am having trouble understanding how pysnmp works. The examples I find online are out of date, don't work, or are confusing for me.

This is my code:
from pysnmp.hlapi.v3arch import *

community_string = 'mystring'
host = 'my_host'

x = get_cmd(SnmpEngine(),
           CommunityData(community_string),
           UdpTransportTarget.create((host, 161)),
           ContextData(),
           ObjectType(ObjectIdentity('1.3.6.1.2.1.1.5.0')),   # SysName
           lookupMib=False,
           lexicographicMode=False,
           )
           
print(next(x))
When run, I get the following error when I try to print(next(x)):
TypeError: 'coroutine' object is not an iterator

Can someone explain why this is, or better yet, provide a very simple SNMP get example using pysnmp?
Reply


Messages In This Thread
Simple pysnmp example? - by Calab - Mar-20-2025, 03:40 PM
RE: Simple pysnmp example? - by snippsat - Mar-20-2025, 04:44 PM
RE: Simple pysnmp example? - by Calab - Apr-14-2025, 01:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to know coming snmp trap version in python pysnmp? ilknurg 0 3,627 Jan-31-2022, 12:16 PM
Last Post: ilknurg

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020