Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. download&Install PySNMP: in ubuntu sudo easy_install pysnmp
  2. then I've found this example that creates a simple trap event.

 

Code Block
themeMidnight
languagepython
titlepython example
firstline1
linenumberstrue
from pysnmp.entity.rfc3413.oneliner import ntforg
from pysnmp.proto import rfc1902

ntfOrg = ntforg.NotificationOriginator()

ntfOrg.sendNotification(
    ntforg.CommunityData('public'),
    ntforg.UdpTransportTarget(('localhost', 162)),
    'trap',
    ntforg.MibVariable('SNMPv2-MIB', 'coldStart'),
    ('1.3.6.1.2.1.1.1.0', rfc1902.OctetString('my system'))
)

...