9c5499480bc8e7d043c42971692428d3032b9e85
[dcaegen2.git] / docs / sections / services / snmptrap / installation.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. _snmptrap-installation:
4
5 Installation
6 ============
7
8 An environment suitable for running docker containers is recommended.
9 If that is not available, SNMPTRAP source can be downloaded and run
10 in a VM or on baremetal.  
11
12 Both scenarios are documented below.
13
14 As a docker container
15 ---------------------
16
17 **trapd** is delivered as a docker container based on python 3.6.  The 
18 host or VM that will run this container must have the docker application 
19 loaded and available to the userID that will be running the SNMPTRAP container.
20
21 If running from a docker container, it is assumed that *Config
22 Binding Service* has been installed and is successfully providing valid
23 configuration assets to instantiated containers as needed.
24
25 Also required is a working DMAAP/MR environment.  trapd
26 publishes traps to DMAAP/MR as JSON messages and expects the host
27 resources and publishing credentials to be included in the *Config Binding Service*
28 config.
29
30 Installation
31 ^^^^^^^^^^^^
32
33 The following command will download the latest trapd container from
34 nexus and launch it in the container named "trapd":
35
36     ``docker run --detach -t --rm -p 162:6162/udp -P --name=trapd nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.snmptrap:2.0.6 ./bin/snmptrapd.sh start``
37
38 Running an instance of **trapd** will result in arriving traps being published
39 to the topic specified by Config Binding Services.  
40
41 Standalone
42 ----------
43
44 **trapd** can also be run outside of a container environment, without CBS interactions. 
45 If CBS is not present, SNMPTRAP will look for a JSON configuration file specified via the
46 environment variable CBS_SIM_JSON at startup.  Location of this file should be specified
47 as a relative path from the <SNMPTRAP base directory>/bin directory. E.g.
48
49 Installation
50 ^^^^^^^^^^^^
51
52 Prerequisites
53 """""""""""""
54
55 trapd requires the following to run in a non-docker environment:
56
57     - Python 3.6+
58     - Python module “pysnmp” 4.4.5
59     - Python module “requests” 2.18.3
60
61 To install prerequisites:
62
63     ``export PATH=<path to Python 3.6 binary>:$PATH``
64
65     ``pip3 install --no-cache-dir requests==2.18.3``
66
67     ``pip3 install --no-cache-dir pysnmp==4.4.5``
68
69 Download latest trapd version from Gerrit
70 """""""""""""""""""""""""""""""""""""""""
71
72 Download a copy of the latest trapd image from gerrit in it's standard runtime location:
73
74     ``cd /opt/app``
75
76     ``git clone --depth 1 ssh://<your linux foundation id>@gerrit.onap.org:29418/dcaegen2/collectors/snmptrap snmptrap``
77
78 "Un-dockerize"
79 """"""""""""""
80
81     ``mv /opt/app/snmptrap/snmptrap /opt/app/snmptrap/bin``
82
83 Configure for your environment
84 """"""""""""""""""""""""""""""
85
86 In a non-docker environment, ONAP trapd is controlled by a locally hosted JSON configuration file.  It is 
87 referenced in the trapd startup script as:
88
89 .. code-block:: bash
90
91     CBS_SIM_JSON=../etc/snmptrapd.json
92
93
94 This file should be in the exact same format is the response from CBS in a fully implemented container/controller environment.  A sample file is included with source/container images, at:
95
96 .. code-block:: bash
97
98     /opt/app/snmptrap/etc/snmptrapd.json
99
100 Make applicable changes to this file - typically things that will need to change include: 
101
102 .. code-block:: bash
103
104     "topic_url": "http://localhost:3904/events/ONAP-COLLECTOR-SNMPTRAP"
105
106 Action:  Change 'localhost' and topic name (ONAP-COLLECTOR-SNMPTRAP) to desired values in your environment.
107
108 .. code-block:: bash
109
110     "snmpv3_config" (needed only when SNMPv3 agents are present)
111
112 Action:  Add/delete/modify entries as needed to align with SNMP agent configurations in a SNMPv3 environment.
113
114 Start the application
115 """""""""""""""""""""
116
117     ``nohup /opt/app/snmptrap/bin/snmptrapd.sh start > /opt/app/snmptrap/logs/snmptrapd.out 2>&1 &``
118