NEW: librenms on debian

This commit is contained in:
KF 2023-08-17 07:13:58 +08:00
parent 616935c781
commit 6c9fb625b6
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
5 changed files with 67 additions and 0 deletions

20
debian/librenms/Dockerfile vendored Normal file
View File

@ -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"]

9
debian/librenms/crontab vendored Normal file
View File

@ -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

16
debian/librenms/nms-spv.conf vendored Normal file
View File

@ -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

21
debian/librenms/nms-vhost.conf vendored Normal file
View File

@ -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;
}
}

1
debian/librenms/start.sh vendored Executable file
View File

@ -0,0 +1 @@
docker run -d --name nms --network macvlan --ip 192.168.86.144 debian/librenms