summaryrefslogtreecommitdiff
path: root/examples/hlapi/v3arch/asyncore/sync/agent/ntforg/custom-contextengineid.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hlapi/v3arch/asyncore/sync/agent/ntforg/custom-contextengineid.py')
-rw-r--r--examples/hlapi/v3arch/asyncore/sync/agent/ntforg/custom-contextengineid.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/examples/hlapi/v3arch/asyncore/sync/agent/ntforg/custom-contextengineid.py b/examples/hlapi/v3arch/asyncore/sync/agent/ntforg/custom-contextengineid.py
index 1b9e12d5..18da255f 100644
--- a/examples/hlapi/v3arch/asyncore/sync/agent/ntforg/custom-contextengineid.py
+++ b/examples/hlapi/v3arch/asyncore/sync/agent/ntforg/custom-contextengineid.py
@@ -22,23 +22,26 @@ Functionally similar to:
"""#
from pysnmp.hlapi import *
-errorIndication, errorStatus, errorIndex, varBinds = next(
- sendNotification(SnmpEngine(),
- UsmUserData('usr-md5-none', 'authkey1'),
- UdpTransportTarget(('demo.snmplabs.com', 162)),
- ContextData(OctetString(hexValue='8000000004030201')),
- 'inform',
- NotificationType(
- ObjectIdentity('1.3.6.1.6.3.1.1.5.2')
- ).loadMibs('SNMPv2-MIB')
- )
+iterator = sendNotification(
+ SnmpEngine(),
+ UsmUserData('usr-md5-none', 'authkey1'),
+ UdpTransportTarget(('demo.snmplabs.com', 162)),
+ ContextData(OctetString(hexValue='8000000004030201')),
+ 'inform',
+ NotificationType(
+ ObjectIdentity('1.3.6.1.6.3.1.1.5.2')
+ ).loadMibs('SNMPv2-MIB')
)
+errorIndication, errorStatus, errorIndex, varBinds = next(iterator)
+
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]))