I want to validate if snmp trap messages send was a success or failure and log it.
So I was wondering if I check the return value of transportDispatcher.runDispatcher(), will that give any error code.
What are other options?
I want to validate if snmp trap messages send was a success or failure and log it.
So I was wondering if I check the return value of transportDispatcher.runDispatcher(), will that give any error code.
What are other options?
Assuming you are using synchronous hlapi API, you should inspect errorIndication
- it will contain local SNMP errors:
>>> from pysnmp.hlapi import *
>>> g = sendNotification(SnmpEngine(),
... CommunityData('public'),
... UdpTransportTarget(('demo.snmplabs.com', 162)),
... ContextData(),
... 'trap',
... NotificationType(ObjectIdentity('IF-MIB', 'linkDown')))
>>> next(g)
(None, 0, 0, [])
Remote SNMP errors can't be communicated by the remote party because it's a unidirectional exchange.
Also, PySnmpError
exception can potentially be raised on a hard non-SNMP error.