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