diff options
Diffstat (limited to 'tests/test_snmptrapd_send_test_trap.py')
-rwxr-xr-x | tests/test_snmptrapd_send_test_trap.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_snmptrapd_send_test_trap.py b/tests/test_snmptrapd_send_test_trap.py new file mode 100755 index 0000000..54d522e --- /dev/null +++ b/tests/test_snmptrapd_send_test_trap.py @@ -0,0 +1,40 @@ +from pysnmp.hlapi import * +from pysnmp import debug + +# debug.setLogger(debug.Debug('msgproc')) + +iters = range(0, 10, 1) +for i in iters: + errorIndication, errorStatus, errorIndex, varbinds = next(sendNotification(SnmpEngine(), + CommunityData('not_public'), + UdpTransportTarget(('localhost', 6164)), + ContextData(), + 'trap', + [ObjectType(ObjectIdentity('.1.3.6.1.4.1.999.1'), OctetString('test trap - ignore')), + ObjectType(ObjectIdentity('.1.3.6.1.4.1.999.2'), OctetString('ONAP pytest trap'))]) + ) + + if errorIndication: + print(errorIndication) + else: + print("successfully sent first trap example, number %d" % i) + +for i in iters: + errorIndication, errorStatus, errorIndex, varbinds = next(sendNotification(SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('localhost', 6164)), + ContextData(), + 'trap', + NotificationType( + ObjectIdentity('.1.3.6.1.4.1.74.2.46.12.1.1') + ).addVarBinds( + ('.1.3.6.1.4.1.999.1', OctetString('ONAP pytest trap - ignore (varbind 1)')), + ('.1.3.6.1.4.1.999.2', OctetString('ONAP pytest trap - ignore (varbind 2)')) + ) + ) + ) + + if errorIndication: + print(errorIndication) + else: + print("successfully sent second trap example, number %d" % i) |