1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
8 **trapd** supports the Simple Network Management Protocol (SNMP)
9 standard. It is a well documented and pervasive protocol,
10 used in all networks worldwide.
12 As an API offering, the only way to interact with **trapd** is
13 to send traps that conform to the industry standard specification
14 (RFC1215 - available at https://tools.ietf.org/html/rfc1215 ) to a
15 running instance. To accomplish this, you may:
17 1. Configure SNMP agents to send native traps to a SNMPTRAP instance.
18 In SNMP agent configurations, this is usually accomplished by
19 setting the "trap target" or "snmp manager" to the IP address
20 of the running VM/container hosting SNMPTRAP.
22 2. Simulate a SNMP trap using various freely available utilities. Two
23 examples are provided below, *be sure to change the target
24 ("localhost") and port ("162") to applicable values in your
30 One way to simulate an arriving SNMP trap is to use the Net-SNMP utility/command snmptrap.
31 This command can send V1, V2c or V3 traps to a manager based on the parameters provided.
33 The example below sends a SNMP V1 trap to the specified host. Prior to running this command, export
34 the values of *to_ip_address* (set it to the IP of the VM hosting the ONAP trapd container) and *to_port* (typically
37 ``export to_ip_address=192.168.1.1``
39 ``export to_port=162``
41 Then run the Net-SNMP command/utility:
43 ``snmptrap -d -v 1 -c not_public ${to_ip_address}:${to_portt} .1.3.6.1.4.1.99999 localhost 6 1 '55' .1.11.12.13.14.15 s "test trap"``
47 This will display some "read_config_store open failure" errors;
48 they can be ignored, the trap has successfully been sent to the
49 specified destination.
54 Another way to simulate an arriving SNMP trap is to send one with the python *pysnmp* module. (Note that this
55 is the same module that ONAP trapd is based on).
57 To do this, create a python script called "send_trap.py" with the following contents. You'll need to change the
58 target (from "localhost" to whatever the destination IP/hostname of the trap receiver is) before saving:
60 .. code-block:: python
62 from pysnmp.hlapi import *
63 from pysnmp import debug
65 # debug.setLogger(debug.Debug('msgproc'))
67 errorIndication, errorStatus, errorIndex, varbinds = next(sendNotification(SnmpEngine(),
68 CommunityData('not_public'),
69 UdpTransportTarget(('localhost', 162)),
72 [ObjectType(ObjectIdentity('.1.3.6.1.4.1.999.1'), OctetString('test trap - ignore')),
73 ObjectType(ObjectIdentity('.1.3.6.1.4.1.999.2'), OctetString('ONAP pytest trap'))])
77 print(errorIndication)
79 print("successfully sent trap")
81 To run the pysnmp example:
83 ``python ./send_trap.py``