summaryrefslogtreecommitdiff
path: root/examples/hlapi/v3arch/trollius/agent/ntforg/default-v1-trap.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hlapi/v3arch/trollius/agent/ntforg/default-v1-trap.py')
-rw-r--r--examples/hlapi/v3arch/trollius/agent/ntforg/default-v1-trap.py37
1 files changed, 19 insertions, 18 deletions
diff --git a/examples/hlapi/v3arch/trollius/agent/ntforg/default-v1-trap.py b/examples/hlapi/v3arch/trollius/agent/ntforg/default-v1-trap.py
index 64e61b1d..1e74aa55 100644
--- a/examples/hlapi/v3arch/trollius/agent/ntforg/default-v1-trap.py
+++ b/examples/hlapi/v3arch/trollius/agent/ntforg/default-v1-trap.py
@@ -28,32 +28,33 @@ from pysnmp.hlapi.v3arch.asyncio import *
@trollius.coroutine
def run():
snmpEngine = SnmpEngine()
- (errorIndication,
- errorStatus,
- errorIndex,
- varBinds) = yield trollius.From(
- sendNotification(
- snmpEngine,
- CommunityData('public'), # mpModel=0),
- UdpTransportTarget(('demo.snmplabs.com', 162)),
- ContextData(),
- 'inform',
- NotificationType(
- ObjectIdentity('1.3.6.1.6.3.1.1.5.2')
- ).loadMibs(
- 'SNMPv2-MIB'
- ).addVarBinds(
- ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'),
- ('1.3.6.1.2.1.1.1.0', OctetString('my system'))
- )
+
+ iterator = sendNotification(
+ snmpEngine,
+ CommunityData('public'), # mpModel=0),
+ UdpTransportTarget(('demo.snmplabs.com', 162)),
+ ContextData(),
+ 'inform',
+ NotificationType(
+ ObjectIdentity('1.3.6.1.6.3.1.1.5.2')
+ ).loadMibs(
+ 'SNMPv2-MIB'
+ ).addVarBinds(
+ ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'),
+ ('1.3.6.1.2.1.1.1.0', OctetString('my system'))
)
)
+ (errorIndication, errorStatus,
+ errorIndex, varBinds) = yield trollius.From(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]))