summaryrefslogtreecommitdiff
path: root/examples/hlapi/v3arch/asyncore/sync/agent/ntforg/v3-inform.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hlapi/v3arch/asyncore/sync/agent/ntforg/v3-inform.py')
-rw-r--r--examples/hlapi/v3arch/asyncore/sync/agent/ntforg/v3-inform.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/examples/hlapi/v3arch/asyncore/sync/agent/ntforg/v3-inform.py b/examples/hlapi/v3arch/asyncore/sync/agent/ntforg/v3-inform.py
index 6f02024f..fb9df891 100644
--- a/examples/hlapi/v3arch/asyncore/sync/agent/ntforg/v3-inform.py
+++ b/examples/hlapi/v3arch/asyncore/sync/agent/ntforg/v3-inform.py
@@ -18,28 +18,30 @@ Functionally similar to:
"""#
from pysnmp.hlapi import *
-errorIndication, errorStatus, errorIndex, varBinds = next(
- sendNotification(
- SnmpEngine(),
- UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
- UdpTransportTarget(('demo.snmplabs.com', 162)),
- ContextData(),
- 'inform',
- NotificationType(
- ObjectIdentity('1.3.6.1.6.3.1.1.5.2')
- ).addVarBinds(
- ObjectType(ObjectIdentity('1.3.6.1.2.1.1.5.0'), 'system name')
- ).loadMibs(
- 'SNMPv2-MIB'
- )
+iterator = sendNotification(
+ SnmpEngine(),
+ UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
+ UdpTransportTarget(('demo.snmplabs.com', 162)),
+ ContextData(),
+ 'inform',
+ NotificationType(
+ ObjectIdentity('1.3.6.1.6.3.1.1.5.2')
+ ).addVarBinds(
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.5.0'), 'system name')
+ ).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]))