From 6c9fb625b644d5b57cc4248fe25de1cb6b89fb3d Mon Sep 17 00:00:00 2001 From: KF Date: Thu, 17 Aug 2023 07:13:58 +0800 Subject: [PATCH] NEW: librenms on debian --- debian/librenms/Dockerfile | 20 ++++++++++++++++++++ debian/librenms/crontab | 9 +++++++++ debian/librenms/nms-spv.conf | 16 ++++++++++++++++ debian/librenms/nms-vhost.conf | 21 +++++++++++++++++++++ debian/librenms/start.sh | 1 + 5 files changed, 67 insertions(+) create mode 100644 debian/librenms/Dockerfile create mode 100644 debian/librenms/crontab create mode 100644 debian/librenms/nms-spv.conf create mode 100644 debian/librenms/nms-vhost.conf create mode 100755 debian/librenms/start.sh diff --git a/debian/librenms/Dockerfile b/debian/librenms/Dockerfile new file mode 100644 index 0000000..6f226a0 --- /dev/null +++ b/debian/librenms/Dockerfile @@ -0,0 +1,20 @@ +FROM debian +RUN apt update +RUN apt install -y apt-transport-https lsb-release ca-certificates wget bash acl curl fping git graphviz imagemagick mariadb-client mtr-tiny nginx-full nmap php-cli php-curl php-fpm php-gd php-gmp php-json php-mbstring php-mysql php-snmp php-xml php-zip python3-dotenv python3-pymysql python3-redis python3-setuptools python3-systemd python3-pip rrdtool snmp snmpd whois supervisor cron nginx-confgen +RUN useradd librenms -d /opt/librenms -M -r -s "$(which bash)" +RUN git clone https://github.com/librenms/librenms.git /opt/librenms +RUN chown -R librenms:librenms /opt/librenms; chmod 771 /opt/librenms +RUN sed -i -e 's#;date.timezone.*#date.timezone=Asia/Hong_Kong#' /etc/php/8.2/fpm/php.ini +RUN ln -sf /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime +RUN sed -i 's/www-data/librenms/g' /etc/php/8.2/fpm/pool.d/www.conf +RUN sed -i 's/;listen.mode.*/listen.mode = 0666/g' /etc/php/8.2/fpm/pool.d/www.conf +RUN echo 'php_admin_value[date.timezone] = "Asia/Hong_Kong"' >> /etc/php/8.2/fpm/pool.d/www.conf +RUN su - librenms -c "/opt/librenms/scripts/composer_wrapper.php install --no-dev" +COPY nms-vhost.conf /etc/nginx/sites-enabled/nms-vhost.conf +COPY nms-spv.conf /etc/supervisor/conf.d/nms-spv.conf +RUN cp /opt/librenms/config.php.default /opt/librenms/config.php; chown librenms:librenms /opt/librenms/config.php +RUN pip3 install -r /opt/librenms/requirements.txt --break-system-packages +RUN cp crontab /var/spool/cron/crontabs/librenms; chmod 600 /var/spool/cron/crontabs/librenms +#ENTRYPOINT ["/bin/bash"] +EXPOSE 80 +CMD ["/usr/bin/supervisord", "-n"] diff --git a/debian/librenms/crontab b/debian/librenms/crontab new file mode 100644 index 0000000..46914d8 --- /dev/null +++ b/debian/librenms/crontab @@ -0,0 +1,9 @@ +* * * * * /usr/bin/env php artisan schedule:run --no-ansi --no-interaction +33 */6 * * * /opt/librenms/cronic /opt/librenms/discovery-wrapper.py 1 +*/5 * * * * /opt/librenms/discovery.php -h new >> /dev/null 2>&1 +*/5 * * * * /opt/librenms/cronic /opt/librenms/poller-wrapper.py 16 +* * * * * /opt/librenms/alerts.php >> /dev/null 2>&1 +*/5 * * * * /opt/librenms/poll-billing.php >> /dev/null 2>&1 +01 * * * * /opt/librenms/billing-calculate.php >> /dev/null 2>&1 +*/5 * * * * /opt/librenms/check-services.php >> /dev/null 2>&1 + diff --git a/debian/librenms/nms-spv.conf b/debian/librenms/nms-spv.conf new file mode 100644 index 0000000..5445c6e --- /dev/null +++ b/debian/librenms/nms-spv.conf @@ -0,0 +1,16 @@ +[program:nginx] +command=/usr/sbin/nginx -g "daemon off;" +autostart=true +autorestart=true +killasgroup=true +stopasgroup=true + +[program:phpfpm] +command=/usr/sbin/php-fpm8.2 -c /etc/php/8.2/fpm/pool.d/www.conf -F +autostart=true +autorestart=true + +[program:crond] +command=/usr/sbin/cron -f +autostart=true +autorestart=true diff --git a/debian/librenms/nms-vhost.conf b/debian/librenms/nms-vhost.conf new file mode 100644 index 0000000..49bfe82 --- /dev/null +++ b/debian/librenms/nms-vhost.conf @@ -0,0 +1,21 @@ +server { + listen 80; + server_name nms.zoo.lo; + root /opt/librenms/html; + index index.php; + + charset utf-8; + gzip on; + gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon; + location / { + try_files $uri $uri/ /index.php?$query_string; + } + location ~ [^/]\.php(/|$) { + fastcgi_pass unix:/run/php/php8.2-fpm.sock; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + include fastcgi.conf; + } + location ~ /\.(?!well-known).* { + deny all; + } +} diff --git a/debian/librenms/start.sh b/debian/librenms/start.sh new file mode 100755 index 0000000..37c441c --- /dev/null +++ b/debian/librenms/start.sh @@ -0,0 +1 @@ +docker run -d --name nms --network macvlan --ip 192.168.86.144 debian/librenms