You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For each Host, SNMPEngine object is initialized and it is takes lot of time and CPU due to lot __manageColumns, exportSymbols activities.
Is it possible to use one SNMPEngine object to query all hosts EngineID ? If there other way to query only EngineID from 250+ hosts concurrently ?
Script:
import asyncio
import pysnmp.hlapi.asyncio as snmp
import time
from pysnmp import debug
debug.setLogger(debug.Debug("all", 'dsp', 'msgproc', 'secmod'))
Hi,
Script:
import asyncio
import pysnmp.hlapi.asyncio as snmp
import time
from pysnmp import debug
debug.setLogger(debug.Debug("all", 'dsp', 'msgproc', 'secmod'))
async def get(host, port, user, oid, timeout=5, retries=1):
result = []
try:
snmpEngine = snmp.SnmpEngine()
transportTarget = snmp.UdpTransportTarget((host, port), timeout=timeout, retries= retries)
observerContext = {}
snmpEngine.observer.registerObserver(lambda e, p, v, c: c.update(securityEngineId=v['securityEngineId']), 'rfc3412.prepareDataElements:internal', cbCtx=observerContext)
authData = snmp.UsmUserData(user)
async def main():
st = time.time()
tasks = []
tasks.append(get('192.168.50.124', 161, "AUTHPRIV", '1.3.6.1.2.1.1.1.0', 5, 1))
tasks.append(get('192.168.50.124', 161, "AUTHPRIV", '1.3.6.1.2.1.1.1.0', 5, 1))
tasks.append(get('192.168.50.124', 161, "AUTHPRIV", '1.3.6.1.2.1.1.1.0', 5, 1))
tasks.append(get('192.168.50.124', 161, "AUTHPRIV", '1.3.6.1.2.1.1.1.0', 5, 1))
tasks.append(get('192.168.50.124', 161, "AUTHPRIV", '1.3.6.1.2.1.1.1.0', 5, 1))
tasks.append(get('192.168.50.124', 161, "AUTHPRIV", '1.3.6.1.2.1.1.1.0', 5, 1))
tasks.append(get('192.168.50.124', 161, "AUTHPRIV", '1.3.6.1.2.1.1.1.0', 5, 1))
tasks.append(get('192.168.50.124', 161, "AUTHPRIV", '1.3.6.1.2.1.1.1.0', 5, 1))
tasks.append(get('192.168.50.124', 161, "AUTHPRIV", '1.3.6.1.2.1.1.1.0', 5, 1))
tasks.append(get('192.168.50.124', 161, "AUTHPRIV", '1.3.6.1.2.1.1.1.0', 5, 1))
print ("Time taken to append ", time.time() - st)
results = list(filter(lambda a: a, await asyncio.gather(*tasks)))
print(f'main() results: {results}')
if name == 'main':
asyncio.run(main())
Thanks in advance,
Ganesh
The text was updated successfully, but these errors were encountered: