From c6aa8dce75476de5cdea904d855c0fc78a1d61b6 Mon Sep 17 00:00:00 2001 From: elie Date: Thu, 30 Aug 2012 20:50:42 +0000 Subject: more updates --- docs/pysnmp-tutorial.html | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'docs') diff --git a/docs/pysnmp-tutorial.html b/docs/pysnmp-tutorial.html index eb47d85..3e54df2 100644 --- a/docs/pysnmp-tutorial.html +++ b/docs/pysnmp-tutorial.html @@ -574,7 +574,7 @@ Create a SNMP Command Generator object.

Although instantiation of this class is cheap, in the course of its further -use, SNMP engine configuration is built and maintained though methods infocation. +use, SNMP engine configuration is built and maintained though methods invocation. Therefore it is advised to keep and reuse CommandGenerator instance (or snmpEngine instance if passed as an initializer) for as long as possible within user applicatin.

@@ -1021,7 +1021,7 @@ errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.bulkCmd( cmdgen.UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', authProtocol=cmdgen.usmHMACSHAAuthProtocol, privProtocol=cmdgen.usmAesCfb128Protocol), - cmdgen.UdpTransportTarget(('localhost', 161)), + cmdgen.Udp6TransportTarget(('::1', 161)), 0, 20, cmdgen.MibVariable('SNMPv2-MIB', 'system') ) @@ -1114,26 +1114,32 @@ in getCmd method.

-The following code sends SNMP TRAP over SNMPv3: +The following code sends SNMP TRAP message: +

-
->>> from pysnmp.entity.rfc3413.oneliner import cmdgen, ntforg
->>> from pysnmp.proto.api import v2c
->>>
->>> ntfOrg = ntforg.NotificationOriginator()
->>> errorIndication = ntfOrg.sendNotification(
-... cmdgen.UsmUserData('my-user', 'my-authkey', 'my-privkey'),
-... cmdgen.UdpTransportTarget(('localhost', 162)),
-... 'trap',
-... cmdgen.MibVariable('SNMPv2-MIB', 'coldStart'),
-... ('1.3.6.1.2.1.1.3.0', v2c.TimeTicks(44100))
+from pysnmp.entity.rfc3413.oneliner import ntforg
+
+ntfOrg = ntforg.NotificationOriginator()
+
+errorIndication = ntfOrg.sendNotification(
+    ntforg.CommunityData('public'),
+    ntforg.UdpTransportTarget(('localhost', 162)),
+    'trap',
+    ntforg.MibVariable('SNMPv2-MIB', 'coldStart'),
+    (ntforg.MibVariable('SNMPv2-MIB', 'sysName', 0), 'new name')
 )
->>> print(errorIndication)
-None
->>> print(errorStatus)
-0
+
+if errorIndication:
+    print('Notification not sent: %s' % errorIndication)
 
-- cgit v1.2.1