Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mk_livestatus #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ENV NG_CGI_URL /cgi-bin
ENV NAGIOS_BRANCH nagios-4.4.5
ENV NAGIOS_PLUGINS_BRANCH release-2.2.1
ENV NRPE_BRANCH nrpe-3.2.1
ENV MK_LIVESTATUS_VERSION 1.2.8p18


RUN echo postfix postfix/main_mailer_type string "'Internet Site'" | debconf-set-selections && \
Expand Down Expand Up @@ -79,6 +80,7 @@ RUN echo postfix postfix/main_mailer_type string "'Internet Site'" | debconf-set
snmp-mibs-downloader \
unzip \
python \
xinetd \
&& \
apt-get clean && rm -Rf /var/lib/apt/lists/*

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

RUN cd /tmp && \
wget https://mathias-kettner.de/download/mk-livestatus-${MK_LIVESTATUS_VERSION}.tar.gz && \
tar zxf mk-livestatus-${MK_LIVESTATUS_VERSION}.tar.gz && \
cd mk-livestatus-${MK_LIVESTATUS_VERSION} && \
./configure --with-nagios4 && \
make && \
make install && \
cd /tmp && rm -Rf mk-livestatus-${MK_LIVESTATUS_VERSION} && \
cd /tmp && rm -f mk-livestatus-${MK_LIVESTATUS_VERSION}.tar.gz

RUN mkdir -p /usr/local/nagios/var/rw && \
chown ${NAGIOS_USER}:${NAGIOS_GROUP} /usr/local/nagios/var/rw

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

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

RUN mkdir -p /orig/var && mkdir -p /orig/etc && \
cp -Rp ${NAGIOS_HOME}/var/* /orig/var/ && \
cp -Rp ${NAGIOS_HOME}/etc/* /orig/etc/
RUN mkdir -p /orig/var && \
mkdir -p /orig/etc && \
mkdir -p /orig/xinetd.d && \
cp -Rp ${NAGIOS_HOME}/var/* /orig/var/ && \
cp -Rp ${NAGIOS_HOME}/etc/* /orig/etc/ && \
cp -Rp /etc/xinetd.d/* /orig/xinetd.d/

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

EXPOSE 80
EXPOSE 6557

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

Expand Down
3 changes: 3 additions & 0 deletions overlay/etc/sv/xinetd/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

exec /usr/sbin/xinetd -f /etc/xinetd.conf -dontfork
14 changes: 14 additions & 0 deletions overlay/etc/xinetd.d/livestatus
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
service livestatus
{
type = UNLISTED
port = 6557
socket_type = stream
protocol = tcp
wait = no
cps = 100 3
flags = NODELAY
user = nagios
server = /usr/local/bin/unixcat
server_args = /usr/local/nagios/var/rw/live
disable = no
}
2 changes: 1 addition & 1 deletion overlay/opt/nagios/etc/nagios.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ event_broker_options=-1

#broker_module=/somewhere/module1.o
#broker_module=/somewhere/module2.o arg1 arg2=3 debug=0

broker_module=/usr/local/lib/mk-livestatus/livestatus.o /usr/local/nagios/var/rw/live event_broker_options=-1


# LOG ROTATION METHOD
Expand Down
6 changes: 5 additions & 1 deletion overlay/usr/local/bin/start_nagios
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ if [ -z "$(ls -A /opt/nagios/var)" ]; then
cp -Rp /orig/var/* /opt/nagios/var/
fi

if [ -z "$(ls -A /etc/xinetd.d)" ]; then
echo "Started with empty xinetd config, copying example data in-place"
cp -Rp /orig/xinetd.d/* /etc/xinetd.d/
fi

if [ ! -f "${NAGIOS_HOME}/etc/htpasswd.users" ] ; then
htpasswd -c -b -s "${NAGIOS_HOME}/etc/htpasswd.users" "${NAGIOSADMIN_USER}" "${NAGIOSADMIN_PASS}"
chown -R ${NAGIOS_USER}.${NAGIOS_GROUP} "${NAGIOS_HOME}/etc/htpasswd.users"
Expand Down Expand Up @@ -43,4 +48,3 @@ trap shutdown SIGTERM SIGHUP SIGINT
wait "${RUNSVDIR}"

shutdown