from pysnmp.hlapi import *
from pysnmp import debug
debug.setLogger(debug.Debug('msgproc'))
next(sendNotification(SnmpEngine(), CommunityData('public'),
    UdpTransportTarget(('demo.snmplabs.com', 162)), ContextData(), 'trap',
    [ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0'), OctetString(
    'my string')), ObjectType(ObjectIdentity('1.3.6.1.2.1.1.3.0'),
    Integer32(42))]))
Sending SNMP Traps containing custom data