from pysnmp.entity.rfc3413.oneliner import ntforg ntfOrg = ntforg.NotificationOriginator() errorIndication = ntfOrg.sendNotification( ntforg.CommunityData('public'), ntforg.UdpTransportTarget(('192.168.0.147', 162)), 'trap', ntforg.MibVariable('MY-MIB', 'testTrap'), ) print "snmp sent" + str(errorIndication) if errorIndication: print('Notification not sent: %s' % errorIndication)