Код: Выделить всё
import asyncio
from pysnmp.hlapi.v1arch.asyncio import *
async def run():
snmpDispatcher = SnmpDispatcher()
iterator = await getCmd(
snmpDispatcher,
CommunityData("public", mpModel=0),
await UdpTransportTarget.create(("1.2.3.4", 161),timeout=1,retries=0),
("1.3.6.1.2.1.1.1.0", None),
)
errorIndication, errorStatus, errorIndex, varBinds = iterator
if errorIndication:
print(errorIndication)
elif errorStatus:
print(
"{} at {}".format(
errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or "?",
)
)
else:
for varBind in varBinds:
print(" = ".join([x.prettyPrint() for x in varBind]))
snmpDispatcher.transportDispatcher.closeDispatcher()
asyncio.run(run())
Кто-нибудь знает хороший способ сделать это?
Подробнее здесь: https://stackoverflow.com/questions/790 ... p-requests