From 1341c91ccc8e346064bdffc4a90eec9e952a3f4a Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Tue, 12 Apr 2016 08:30:52 +0200 Subject: TRAP example added --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index accf1c68..17bb56fb 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,28 @@ else: print(' = '.join([x.prettyPrint() for x in varBind])) ``` +or, to send SNMP TRAP: + +```python +from pysnmp.hlapi import * + +errorIndication, errorStatus, errorIndex, varBinds = next( + sendNotification( + SnmpEngine(OctetString(hexValue='8000000001020304')), + UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', + authProtocol=usmHMACSHAAuthProtocol, + privProtocol=usmAesCfb128Protocol), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'trap', + NotificationType(ObjectIdentity('SNMPv2-MIB', 'authenticationFailure')) + ) +) + +if errorIndication: + print(errorIndication) +``` + We maintain publicly available SNMP Agent and TRAP sink at [demo.snmplabs.com](http://snmpsim.sourceforge.net/public-snmp-simulator.html). You are welcome to play with it while experimenting with your PySNMP scripts. -- cgit v1.2.1