-
Notifications
You must be signed in to change notification settings - Fork 74
/
.travis.yml
268 lines (236 loc) · 10.7 KB
/
.travis.yml
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
language: python
python:
- '3.6'
env:
matrix:
- DJANGO_VERSION="Django<1.9"
global:
- secure=fNl4/GNkavnuvJVtPEj0PDt23143mtqMzrrv4iHUWfePQpHthMoNRsm5g5z/UTIwgDKqaK/EAxxtH5u1Bfq2Z4HEcpgsy48AI2uXGDZV+z++11XgXmTR9Jejn47iKVJHgIEItIMJYw/3WngP7oqVhd/5qgLcUF5ywBtbEflRSgQ=
- NAGIOS_HOME=/usr/local/nagios
- NAGIOS_USER=nagios
- NAGIOS_GROUP=nagios
- NAGIOS_CMDUSER=nagios
- NAGIOS_CMDGROUP=nagios
- NAGIOS_FQDN=nagios.example.com
- NAGIOSADMIN_USER=nagiosadmin
- NAGIOSADMIN_PASS=nagios
- APACHE_RUN_USER=nagios
- APACHE_RUN_GROUP=nagios
- NAGIOS_TIMEZONE=UTC
- DEBIAN_FRONTEND=noninteractive
- NG_NAGIOS_CONFIG_FILE=${NAGIOS_HOME}/etc/nagios.cfg
- NG_CGI_DIR=${NAGIOS_HOME}/sbin
- NG_CGI_URL=/cgi-bin
- NAGIOS_BRANCH=nagios-4.4.3
- NAGIOS_PLUGINS_BRANCH=release-2.2.1
- NRPE_BRANCH=nrpe-3.2.1
- APACHE_LOCK_DIR=/var/run
- APACHE_LOG_DIR=/var/log/apache2
- PNP4NAGIOS_MODULE=${NAGIOS_HOME}/lib/npcdmod.o
- PNP4NAGIOS_CONFIG_FILE=${NAGIOS_HOME}/etc/pnp/npcd.cfg
install:
- whoami
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update
- sudo apt-get install python-pip python-dev build-essential git unzip -y
- pip install coveralls
- sudo apt-get install -y apache2 apache2-utils autoconf automake bc bsd-mailx build-essential dnsutils fping gettext git gperf iputils-ping jq libapache2-mod-php libcache-memcached-perl libcgi-pm-perl libdbd-mysql-perl libdbi-dev libdbi-perl libfreeradius-client-dev libgd2-xpm-dev libgd-gd2-perl libjson-perl libldap2-dev libmysqlclient-dev libnagios-object-perl libnagios-plugin-perl libnet-snmp-perl libnet-snmp-perl libnet-tftp-perl libnet-xmpp-perl libpq-dev libredis-perl librrds-perl libssl-dev libswitch-perl libwww-perl m4 netcat parallel php-cli php-gd postfix python-pip rsyslog smbclient snmp snmpd unzip python
- sudo apt-get install -y gcc-7 g++-7 librrd-dev rrdtool libboost-filesystem-dev libboost-thread-dev
- sudo apt-get clean
- sudo rm -Rf /var/lib/apt/lists/*
- ( egrep -i "^${NAGIOS_GROUP}" /etc/group || sudo groupadd $NAGIOS_GROUP )
- ( egrep -i "^${NAGIOS_CMDGROUP}" /etc/group || sudo groupadd $NAGIOS_CMDGROUP )
- ( id -u $NAGIOS_USER || sudo useradd --system -d $NAGIOS_HOME -g $NAGIOS_GROUP $NAGIOS_USER )
- ( id -u $NAGIOS_CMDUSER || sudo useradd --system -d $NAGIOS_HOME -g $NAGIOS_CMDGROUP $NAGIOS_CMDUSER )
- sudo usermod -aG nagios travis
# Install Nagios
- cd /tmp
- sudo git clone https://github.com/NagiosEnterprises/nagioscore.git -b $NAGIOS_BRANCH
- cd nagioscore
- sudo ./configure
--prefix=${NAGIOS_HOME}
--exec-prefix=${NAGIOS_HOME}
--enable-event-broker
--with-command-user=${NAGIOS_CMDUSER}
--with-command-group=${NAGIOS_CMDGROUP}
--with-nagios-user=${NAGIOS_USER}
--with-nagios-group=${NAGIOS_GROUP}
- sudo make all
- sudo make install
- sudo make install-config
- sudo make install-commandmode
- sudo make install-webconf
- sudo make install-init
- sudo make install-daemoninit
- sudo make clean
- cd /tmp && sudo rm -Rf nagioscore
# Install Nagios Plugins
- cd /tmp
- sudo git clone https://github.com/nagios-plugins/nagios-plugins.git -b $NAGIOS_PLUGINS_BRANCH
- cd nagios-plugins
- sudo ./tools/setup
- sudo ./configure
--prefix=${NAGIOS_HOME}
--with-ipv6
--with-ping6-command="/bin/ping6 -n -U -W %d -c %d %s"
- sudo make
- sudo make install
- sudo make clean
- sudo mkdir -p /usr/lib/nagios/plugins
- sudo ln -sf ${NAGIOS_HOME}/libexec/utils.pm /usr/lib/nagios/plugins
- sudo wget -O ${NAGIOS_HOME}/libexec/check_ncpa.py https://raw.githubusercontent.com/NagiosEnterprises/ncpa/v2.0.5/client/check_ncpa.py
- sudo chmod +x ${NAGIOS_HOME}/libexec/check_ncpa.py
# Install NRPE
- cd /tmp
- sudo git clone https://github.com/NagiosEnterprises/nrpe.git -b $NRPE_BRANCH
- cd nrpe
- sudo ./configure
--with-ssl=/usr/bin/openssl
--with-ssl-lib=/usr/lib/x86_64-linux-gnu
- sudo make check_nrpe
- sudo cp src/check_nrpe ${NAGIOS_HOME}/libexec/
- sudo make clean
- cd /tmp && sudo rm -Rf nrpe
# Install PNP4Nagios
# Build/Install PNP4Nagios
- cd /tmp
#- sudo wget http://downloads.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.24.tar.gz
- sudo wget https://github.com/lingej/pnp4nagios/archive/0.6.24.tar.gz
- sudo tar -xzvf 0.6.24.tar.gz
- cd pnp4nagios-0.6.24
- sudo ./configure
--prefix=${NAGIOS_HOME}
--with-nagios-user=${NAGIOS_USER}
--with-nagios-group=${NAGIOS_GROUP}
--sysconfdir=${NAGIOS_HOME}/etc/pnp
--exec-prefix=${NAGIOS_HOME}
--datarootdir=${NAGIOS_HOME}/share/pnp
--with-rrdtool=/usr/bin/rrdtool
--sysconfdir=${NAGIOS_HOME}/etc/pnp
--with-perfdata-dir=${NAGIOS_HOME}/share/perfdata
--with-perfdata-logfile=${NAGIOS_HOME}/var/perfdata.log
--with-perfdata-spool-dir=${NAGIOS_HOME}/var/spool/perfdata
- sudo make all
- sudo make install
- sudo make install-webconf
- sudo make install-config
- sudo make install-init
- sudo /etc/init.d/npcd start
# Configuration
- export DOC_ROOT="DocumentRoot $(echo $NAGIOS_HOME/share)"
- sudo sed -i "s,DocumentRoot.*,$DOC_ROOT," /etc/apache2/sites-enabled/000-default.conf
- sudo sed -i "s,</VirtualHost>,<IfDefine ENABLE_USR_LIB_CGI_BIN>\nScriptAlias /cgi-bin/ ${NAGIOS_HOME}/sbin/\n</IfDefine>\n</VirtualHost>," /etc/apache2/sites-enabled/000-default.conf
- sudo ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/cgi.load
#- sudo mkdir -p -m 0755 /usr/share/snmp/mibs
- sudo mkdir -p ${NAGIOS_HOME}/etc/conf.d
- sudo mkdir -p ${NAGIOS_HOME}/etc/monitor
- sudo mkdir -p -m 700 ${NAGIOS_HOME}/.ssh
- sudo chown ${NAGIOS_USER}:${NAGIOS_GROUP} ${NAGIOS_HOME}/.ssh
#- sudo touch /usr/share/snmp/mibs/.foo
#- sudo ln -s /usr/share/snmp/mibs ${NAGIOS_HOME}/libexec/mibs
- sudo ln -s ${NAGIOS_HOME}/bin/nagios /usr/local/bin/nagios
#- sudo download-mibs
- sudo sed -i 's,/bin/mail,/usr/bin/mail,' ${NAGIOS_HOME}/etc/objects/commands.cfg
- sudo sed -i 's,/usr/usr,/usr,' ${NAGIOS_HOME}/etc/objects/commands.cfg
- sudo cp /etc/services /var/spool/postfix/etc/
- sudo rm -rf /etc/rsyslog.d /etc/rsyslog.conf
- sudo rm -rf /etc/sv/getty-5
- echo "checking permissions for nagios"
- sudo find /usr/local/nagios \! -user ${NAGIOS_USER} -exec sudo chown ${NAGIOS_USER}:${NAGIOS_GROUP} '{}' +
#- echo "use_timezone=${NAGIOS_TIMEZONE}" >> ${NAGIOS_HOME}/etc/nagios.cfg
- sudo mkdir -p /orig/var && sudo mkdir -p /orig/etc
- sudo cp -Rp ${NAGIOS_HOME}/var/* /orig/var/
- sudo cp -Rp ${NAGIOS_HOME}/etc/* /orig/etc/
- sudo a2enmod session
- sudo a2enmod session_cookie
- sudo a2enmod session_crypto
- sudo a2enmod auth_form
- sudo a2enmod request
- export APACHE_LOCK_DIR=/var/run
- export APACHE_LOG_DIR=/var/log/apache2
- sudo usermod -G www-data nagios
- pip install future
- pip install $DJANGO_VERSION
- pip install mock
- pip install simplejson
- pip install paramiko
- pip install selenium
# Install Livestatus
- cd /tmp
- wget https://checkmk.com/support/1.5.0p16/check-mk-raw-1.5.0p16.cre.tar.gz
- tar -zxvf check-mk-raw-1.5.0p16.cre.tar.gz
- tar -zxvf check-mk-raw-1.5.0p16.cre/mk-livestatus-1.5.0p16.tar.gz
- cd mk-livestatus-1.5.0p16
- sudo ./configure --with-nagios4 --prefix=${NAGIOS_HOME}
- sudo make
- sudo make install
# Install Pynag
#- pip install pynag
- pip install git+https://github.com/pynag/pynag.git
# Install Adagios
- cd ~/build/opinkerfi/adagios/
- python setup.py build
- python setup.py install
# Configuration
- sudo mkdir -p /var/lib/adagios
- sudo chown -R travis:travis /var/lib/adagios
- sudo mkdir -p /etc/adagios/conf.d
- sudo cp -r adagios/etc/adagios/adagios.conf /etc/adagios/
- sudo cp adagios/etc/sudoers.d/adagios /etc/sudoers.d/
- sudo cp adagios/etc/adagios/conf.d/okconfig.conf /etc/adagios/conf.d/
- sudo chown -R travis:travis /etc/adagios
- sudo mkdir -p ${NAGIOS_HOME}/etc/adagios
- sudo chown -R nagios:nagios ${NAGIOS_HOME}
- sudo chmod -R 775 ${NAGIOS_HOME}
- sudo chmod g+s ${NAGIOS_HOME}
- sudo setfacl -R -m group:nagios:rwx -m d:group:nagios:rwx ${NAGIOS_HOME} /etc/okconfig /etc/adagios /var/lib/adagios
- sudo setfacl -R -m group:travis:rwx -m d:group:travis:rwx ${NAGIOS_HOME} /etc/okconfig /etc/adagios /var/lib/adagios
# Install OKconfig
- git clone https://github.com/opinkerfi/okconfig.git ~/build/opinkerfi/okconfig
- cd ~/build/opinkerfi/okconfig/
- python setup.py build
- sudo python setup.py install
- python setup.py install
- sudo touch /etc/okconfig.conf
- sudo chown travis /etc/okconfig.conf
- echo "nagios_config ${NAGIOS_HOME}/etc/nagios.cfg" >> /etc/okconfig.conf
- echo "template_directory ${NAGIOS_HOME}/etc/okconfig/templates" >> /etc/okconfig.conf
- echo "examples_directory ${NAGIOS_HOME}/etc/okconfig/examples" >> /etc/okconfig.conf
- echo "destination_directory ${NAGIOS_HOME}/etc/okconfig" >> /etc/okconfig.conf
- mkdir -p ${NAGIOS_HOME}/etc/okconfig/templates ${NAGIOS_HOME}/etc/okconfig/examples
- cp -r ~/build/opinkerfi/okconfig/usr/share/okconfig/templates/* ${NAGIOS_HOME}/etc/okconfig/templates/
- cp -r ~/build/opinkerfi/okconfig/usr/share/okconfig/examples/* ${NAGIOS_HOME}/etc/okconfig/examples/
- pynag config --append cfg_dir=${NAGIOS_HOME}/etc/okconfig
- ls -l ${NAGIOS_HOME}/etc/okconfig
# Configure Adagios
- pynag config --append "broker_module=/usr/local/nagios/lib/mk-livestatus/livestatus.o /usr/local/nagios/var/rw/live"
- pynag config --set "process_performance_data=1"
- pynag config --set 'nagios_binary="/usr/sbin/nagios"' --filename /etc/adagios/adagios.conf
- pynag config --set 'nagios_init="/etc/init.d/nagios"' --filename /etc/adagios/adagios.conf
- pynag config --set 'nagios_config="/usr/local/nagios/etc/nagios.cfg"' --filename /etc/adagios/adagios.conf
- pynag config --set 'destination_directory="/usr/local/nagios/etc/adagios/"' --filename /etc/adagios/adagios.conf
- pynag config --set 'nagios_service = "nagios"' --filename /etc/adagios/adagios.conf
- cat /etc/adagios/adagios.conf
- mkdir -p ${NAGIOS_HOME}/etc/okconfig/templates ${NAGIOS_HOME}/etc/okconfig/examples ${NAGIOS_HOME}/etc/adagios /var/lib/adagios
- sudo chown travis:nagios /var/lib/adagios
- pynag config --append cfg_dir=${NAGIOS_HOME}/etc/adagios
- cd ${NAGIOS_HOME}/etc/
- git config --global user.email "noreply@travis-ci.org"
- git config --global user.name "Adagios buildbot running inside travis"
- git init
- git add .
- git commit -a -m "Initial commit"
- sudo service nagios restart
- sudo setfacl -R -m u:travis:rwx /usr/local/nagios
- sudo setfacl -R -m g:nagios:rwx /usr/local/nagios
- sudo setfacl -m u:travis:rwx /usr/local/nagios/var/rw/live
- pynag livestatus --get hosts --columns "name state last_state_change" --limit 9
script:
- cd ~/build/opinkerfi/adagios/adagios
- ls -l ${NAGIOS_HOME}
- nagios -v ${NAGIOS_HOME}/etc/nagios.cfg
#- okconfig verify
- coverage run --source=adagios manage.py test
after_success: coveralls
notifications:
email: false