Skip to content

Commit b8cbafa

Browse files
committed
Add mk_livestatus
1 parent 656fe71 commit b8cbafa

5 files changed

Lines changed: 44 additions & 5 deletions

File tree

Dockerfile

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ENV NG_CGI_URL /cgi-bin
2020
ENV NAGIOS_BRANCH nagios-4.4.5
2121
ENV NAGIOS_PLUGINS_BRANCH release-2.2.1
2222
ENV NRPE_BRANCH nrpe-3.2.1
23+
ENV MK_LIVESTATUS_VERSION 1.2.8p18
2324

2425

2526
RUN echo postfix postfix/main_mailer_type string "'Internet Site'" | debconf-set-selections && \
@@ -79,6 +80,7 @@ RUN echo postfix postfix/main_mailer_type string "'Internet Site'" | debconf-set
7980
snmp-mibs-downloader \
8081
unzip \
8182
python \
83+
xinetd \
8284
&& \
8385
apt-get clean && rm -Rf /var/lib/apt/lists/*
8486

@@ -173,6 +175,18 @@ RUN cd /opt
173175
cp /opt/nagios-mssql/check_mssql_database.py ${NAGIOS_HOME}/libexec/ && \
174176
cp /opt/nagios-mssql/check_mssql_server.py ${NAGIOS_HOME}/libexec/
175177

178+
RUN cd /tmp && \
179+
wget https://mathias-kettner.de/download/mk-livestatus-${MK_LIVESTATUS_VERSION}.tar.gz && \
180+
tar zxf mk-livestatus-${MK_LIVESTATUS_VERSION}.tar.gz && \
181+
cd mk-livestatus-${MK_LIVESTATUS_VERSION} && \
182+
./configure --with-nagios4 && \
183+
make && \
184+
make install && \
185+
cd /tmp && rm -Rf mk-livestatus-${MK_LIVESTATUS_VERSION} && \
186+
cd /tmp && rm -f mk-livestatus-${MK_LIVESTATUS_VERSION}.tar.gz
187+
188+
RUN mkdir -p /usr/local/nagios/var/rw && \
189+
chown ${NAGIOS_USER}:${NAGIOS_GROUP} /usr/local/nagios/var/rw
176190

177191
RUN sed -i.bak 's/.*\=www\-data//g' /etc/apache2/envvars
178192
RUN export DOC_ROOT="DocumentRoot $(echo $NAGIOS_HOME/share)" && \
@@ -206,9 +220,12 @@ RUN echo "use_timezone=${NAGIOS_TIMEZONE}" >> ${NAGIOS_HOME}/etc/nagios.cfg
206220

207221
# Copy example config in-case the user has started with empty var or etc
208222

209-
RUN mkdir -p /orig/var && mkdir -p /orig/etc && \
210-
cp -Rp ${NAGIOS_HOME}/var/* /orig/var/ && \
211-
cp -Rp ${NAGIOS_HOME}/etc/* /orig/etc/
223+
RUN mkdir -p /orig/var && \
224+
mkdir -p /orig/etc && \
225+
mkdir -p /orig/xinetd.d && \
226+
cp -Rp ${NAGIOS_HOME}/var/* /orig/var/ && \
227+
cp -Rp ${NAGIOS_HOME}/etc/* /orig/etc/ && \
228+
cp -Rp /etc/xinetd.d/* /orig/xinetd.d/
212229

213230
RUN a2enmod session && \
214231
a2enmod session_cookie && \
@@ -241,6 +258,7 @@ RUN echo "ServerName ${NAGIOS_FQDN}" > /etc/apache2/conf-available/servername.co
241258
ln -s /etc/apache2/conf-available/timezone.conf /etc/apache2/conf-enabled/timezone.conf
242259

243260
EXPOSE 80
261+
EXPOSE 6557
244262

245263
VOLUME "${NAGIOS_HOME}/var" "${NAGIOS_HOME}/etc" "/var/log/apache2" "/opt/Custom-Nagios-Plugins" "/opt/nagiosgraph/var" "/opt/nagiosgraph/etc"
246264

overlay/etc/sv/xinetd/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
exec /usr/sbin/xinetd -f /etc/xinetd.conf -dontfork

overlay/etc/xinetd.d/livestatus

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
service livestatus
2+
{
3+
type = UNLISTED
4+
port = 6557
5+
socket_type = stream
6+
protocol = tcp
7+
wait = no
8+
cps = 100 3
9+
flags = NODELAY
10+
user = nagios
11+
server = /usr/local/bin/unixcat
12+
server_args = /usr/local/nagios/var/rw/live
13+
disable = no
14+
}

overlay/opt/nagios/etc/nagios.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ event_broker_options=-1
222222

223223
#broker_module=/somewhere/module1.o
224224
#broker_module=/somewhere/module2.o arg1 arg2=3 debug=0
225-
225+
broker_module=/usr/local/lib/mk-livestatus/livestatus.o /usr/local/nagios/var/rw/live event_broker_options=-1
226226

227227

228228
# LOG ROTATION METHOD

overlay/usr/local/bin/start_nagios

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ if [ -z "$(ls -A /opt/nagios/var)" ]; then
1414
cp -Rp /orig/var/* /opt/nagios/var/
1515
fi
1616

17+
if [ -z "$(ls -A /etc/xinetd.d)" ]; then
18+
echo "Started with empty xinetd config, copying example data in-place"
19+
cp -Rp /orig/xinetd.d/* /etc/xinetd.d/
20+
fi
21+
1722
if [ ! -f "${NAGIOS_HOME}/etc/htpasswd.users" ] ; then
1823
htpasswd -c -b -s "${NAGIOS_HOME}/etc/htpasswd.users" "${NAGIOSADMIN_USER}" "${NAGIOSADMIN_PASS}"
1924
chown -R ${NAGIOS_USER}.${NAGIOS_GROUP} "${NAGIOS_HOME}/etc/htpasswd.users"
@@ -43,4 +48,3 @@ trap shutdown SIGTERM SIGHUP SIGINT
4348
wait "${RUNSVDIR}"
4449

4550
shutdown
46-

0 commit comments

Comments
 (0)