2021-09-30 23:35:14 -07:00
|
|
|
FROM ubuntu:focal
|
2014-06-26 10:26:28 -07:00
|
|
|
|
|
|
|
# Packages: update & install
|
2021-09-30 23:35:14 -07:00
|
|
|
RUN apt-get update -qq && \
|
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends python3-pip supervisor build-essential apache2 libapache2-mod-php7.4 snmp-mibs-downloader apache2-utils wget curl samba-common samba-common-bin smbclient snmp whois traceroute libgd-dev libssl-dev libnet-snmp-perl libperl-dev libpq5 libsensors5 libsnmp-base libtalloc2 libtdb1 libwbclient0 libmysqlclient-dev unzip inetutils-ping sudo openssh-client bind9-dnsutils file && \
|
|
|
|
pip3 install j2cli && \
|
|
|
|
update-alternatives --install /usr/bin/python python $(which python3) 2 # Workaround for nagios scripts wanting python2 as "python"
|
2014-06-27 04:22:43 -07:00
|
|
|
|
|
|
|
# Const
|
2021-09-30 23:35:14 -07:00
|
|
|
ENV NAGIOS_PHP_TIMEZONE=UTC \
|
|
|
|
NAGIOS_TARBALL=https://phoenixnap.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.4.6/nagios-4.4.6.tar.gz \
|
|
|
|
NAGIOS_PLUGINS_TARBALL=https://www.nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz \
|
|
|
|
NAGIOS_NRPE_TARBALL=https://phoenixnap.dl.sourceforge.net/project/nagios/nrpe-4.x/nrpe-4.0.3/nrpe-4.0.3.tar.gz \
|
|
|
|
NAGIOS_NSCA_TARBALL=https://phoenixnap.dl.sourceforge.net/project/nagios/nsca-2.x/nsca-2.10.0/nsca-2.10.0.tar.gz
|
2014-06-27 04:22:43 -07:00
|
|
|
# Using manual: https://raymii.org/s/tutorials/Nagios_Core_4_Installation_on_Ubuntu_12.04.html
|
|
|
|
|
2021-09-30 23:35:14 -07:00
|
|
|
#https://kent.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz \
|
2014-06-27 04:22:43 -07:00
|
|
|
|
2014-06-26 10:26:28 -07:00
|
|
|
# Users
|
2021-09-30 23:35:14 -07:00
|
|
|
RUN groupadd -g 3000 nagios && \
|
|
|
|
useradd -u 3000 -g nagios -G www-data -m -s /bin/bash nagios
|
2014-06-26 10:26:28 -07:00
|
|
|
|
|
|
|
# Install nagios
|
2021-09-30 23:35:14 -07:00
|
|
|
RUN mkdir -p /usr/local/src/nagios4 && \
|
|
|
|
cd /usr/local/src/nagios4 && \
|
|
|
|
wget -q $NAGIOS_TARBALL -O- | tar -zxp --strip-components 1 && \
|
|
|
|
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagios && \
|
|
|
|
make -j8 all && \
|
|
|
|
make install install-init install-config install-commandmode && \
|
|
|
|
ln -s /usr/local/nagios/etc /etc/nagios
|
2014-06-27 04:22:43 -07:00
|
|
|
|
|
|
|
# Install nagios plugins
|
2021-09-30 23:35:14 -07:00
|
|
|
RUN mkdir -p /usr/local/src/nagios4-plugins && \
|
|
|
|
cd /usr/local/src/nagios4-plugins && \
|
|
|
|
wget -q $NAGIOS_PLUGINS_TARBALL -O- | tar -zxp --strip-components 1 && \
|
|
|
|
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl=/usr/bin/openssl --enable-perl-modules --enable-libtap && \
|
|
|
|
make -j8 && \
|
|
|
|
make install
|
2014-06-27 04:22:43 -07:00
|
|
|
|
|
|
|
# Install nagios NRPE
|
2021-09-30 23:35:14 -07:00
|
|
|
RUN mkdir -p /usr/local/src/nagios4-nrpe && \
|
|
|
|
cd /usr/local/src/nagios4-nrpe && \
|
|
|
|
wget -q $NAGIOS_NRPE_TARBALL -O- | tar -zxp --strip-components 1 && \
|
|
|
|
./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu && \
|
|
|
|
make -j8 all && \
|
|
|
|
make install install-plugin install-daemon install-config
|
2014-06-27 05:39:25 -07:00
|
|
|
|
|
|
|
# Install nagios NSCA
|
2021-09-30 23:35:14 -07:00
|
|
|
RUN mkdir -p /usr/local/src/nagios4-nsca && \
|
|
|
|
cd /usr/local/src/nagios4-nsca && \
|
|
|
|
wget -q $NAGIOS_NSCA_TARBALL -O- | tar -zxp --strip-components 1 && \
|
|
|
|
./configure --with-nsca-user=nagios --with-nsca-grp=nagios && \
|
|
|
|
make -j8 all && \
|
|
|
|
cd /usr/local/src/nagios4-nsca && \
|
|
|
|
cp sample-config/nsca.cfg sample-config/send_nsca.cfg /etc/nagios/ && \
|
|
|
|
cp src/send_nsca src/nsca /usr/local/bin/ && \
|
|
|
|
chmod 644 /etc/nagios/nsca.cfg
|
2014-06-27 04:22:43 -07:00
|
|
|
|
|
|
|
# Clean-up
|
|
|
|
RUN rm -rf /usr/local/src/nagios*
|
|
|
|
|
|
|
|
# Add files
|
|
|
|
ADD conf /root/conf
|
|
|
|
|
|
|
|
# Configure: php
|
2021-09-30 23:35:14 -07:00
|
|
|
RUN j2 /root/conf/php.ini > /etc/php/7.4/mods-available/custom.ini && \
|
|
|
|
phpenmod custom
|
2014-06-27 04:22:43 -07:00
|
|
|
|
|
|
|
# Configure: apache
|
|
|
|
ADD conf/apache2-site.conf /etc/apache2/sites-available/nagios.conf
|
2021-09-30 23:35:14 -07:00
|
|
|
RUN a2dissite 000-default && \
|
|
|
|
a2ensite nagios && \
|
|
|
|
a2enmod cgi
|
2014-06-27 04:22:43 -07:00
|
|
|
|
|
|
|
# Configure: supervisor
|
|
|
|
ADD conf/supervisor-all.conf /etc/supervisor/conf.d/
|
|
|
|
|
|
|
|
# Configure: nagios
|
2021-09-30 23:35:14 -07:00
|
|
|
RUN bash -c 'mkdir -p /etc/nagios/conf.d /etc/nagios/conf.d/{hosts,services,timeperiods,templates,hostgroups,servicegroups,contacts}' && \
|
|
|
|
echo 'cfg_dir=/etc/nagios/conf.d/' >> /etc/nagios/nagios.cfg && \
|
|
|
|
sed -i 's~^url_html_path=.*~url_html_path=/~' /etc/nagios/cgi.cfg
|
2014-06-27 04:22:43 -07:00
|
|
|
|
|
|
|
# Runner
|
|
|
|
ADD run.sh /root/run.sh
|
|
|
|
|
|
|
|
# Declare
|
|
|
|
VOLUME ["/etc/nagios/", "/usr/local/nagios/var/"]
|
|
|
|
EXPOSE 80
|
|
|
|
EXPOSE 5666
|
2014-06-27 05:39:25 -07:00
|
|
|
EXPOSE 5667
|
2014-06-26 10:26:28 -07:00
|
|
|
|
2014-06-27 04:22:43 -07:00
|
|
|
CMD ["/root/run.sh"]
|