pysnmp.sourceforge.net
HOME QUICK START DOCUMENTATION EXAMPLES DOWNLOAD
DEVELOPMENT | CONTACT |

SNMP v1:

TRAP with custom values
TRAP with default values

SNMP v2c:

TRAP with MIB lookup
INFORM with MIB lookup

SNMP v3:

TRAP with custom EngineId
INFORM
INFORM with custom contextName
INFORM with custom contextEngineId

Asynchronous SNMP:

TRAP with multiple transports and protocols
INFORM with multiple transports and protocols
INFORM with multiple SNMP engines

WARNING: you are reading historical documentation! Please, refer here.

Notification Originator

Send SNMP notification using the following options:

The following Net-SNMP's command will produce similar SNMP notification:

$ snmptrap -v2c -c public 127.0.0.1 0 SNMPv2-MIB::coldStart SNMPv2-MIB::sysName.0 = 'new name'

In this example, all MIB objects to be used for building TRAP PDU are specified as MIB symbols what requires MIB lookup. types.

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' )
)

if errorIndication:
    print('Notification not sent: %s' % errorIndication)

To download this example as a Python file, please click here.


Need help? Try PySNMP mailing lists or report to library maintainers.
SourceForge Logo