blob: e9a8afeb67698e2f88d83f2c6fbce58bbb48842d [file] [log] [blame]
Rich Bennett98476312018-08-25 10:43:15 -04001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
3
4Offered APIs
5============
6
7**SNMPTRAP** supports the Simple Network Management Protocol (SNMP)
8standard. It is a well documented and pervasive protocol,
9used in all networks worldwide.
10
11As an API offering, the only way to interact with **SNMPTRAP** is
12to send traps that conform to the industry standard specification
13(RFC1215 - available at https://tools.ietf.org/html/rfc1215 ) to a
14running instance. To accomplish this, you may:
15
161. Configure SNMP agents to send native traps to a SNMPTRAP instance.
17 In SNMP agent configurations, this is usually accomplished by
18 setting the "trap target" or "snmp manager" to the IP address
19 of the running VM/container hosting SNMPTRAP.
20
212. Mimic a SNMP trap using various freely available utilities. Two
22 examples are provided below, be sure to change the target
23 ("localhost") and port ("162") to applicable values in your
24 environment.
25
26Net-SNMP
27--------
28
29.. code-block:: bash
30
31 snmptrap -d -v 1 -c 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"
32
33.. note::
34
35 This will display some "read_config_store open failure" errors;
36 they can be ignored, the trap has successfully been sent to the
37 specified destination.
38
39pysnmp
40------
41
42.. code-block:: python
43
44 from pysnmp.hlapi import *
45 from pysnmp import debug
46
47 # debug.setLogger(debug.Debug('msgproc'))
48
49 errorIndication, errorStatus, errorIndex, varbinds = next(sendNotification(SnmpEngine(),
50 CommunityData('not_public'),
51 UdpTransportTarget(('localhost', 162)),
52 ContextData(),
53 'trap',
54 [ObjectType(ObjectIdentity('.1.3.6.1.4.1.999.1'), OctetString('test trap - ignore')),
55 ObjectType(ObjectIdentity('.1.3.6.1.4.1.999.2'), OctetString('ONAP pytest trap'))])
56 )
57
58 if errorIndication:
59 print(errorIndication)
60 else:
61 print("successfully sent first trap example, number %d" % i)