mirror of
https://github.com/librenms/docker.git
synced 2026-01-23 02:14:48 +00:00
Add LibreNMS Weathermap plugin (#81)
This commit is contained in:
parent
62a083f008
commit
fee60a01c8
9 changed files with 67 additions and 6 deletions
16
Dockerfile
16
Dockerfile
|
|
@ -27,13 +27,12 @@ RUN apk --update --no-cache add \
|
|||
coreutils \
|
||||
curl \
|
||||
fping \
|
||||
git \
|
||||
graphviz \
|
||||
imagemagick \
|
||||
ipmitool \
|
||||
mariadb-client \
|
||||
monitoring-plugins \
|
||||
mtr \
|
||||
mysql-client \
|
||||
net-snmp \
|
||||
net-snmp-tools \
|
||||
nginx \
|
||||
|
|
@ -105,7 +104,9 @@ ENV S6_BEHAVIOUR_IF_STAGE2_FAILS="2" \
|
|||
PUID="1000" \
|
||||
PGID="1000"
|
||||
|
||||
RUN mkdir -p /opt \
|
||||
RUN apk --update --no-cache add -t build-dependencies \
|
||||
git \
|
||||
&& mkdir -p /opt \
|
||||
&& curl -sSL https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
|
||||
&& git clone --branch ${LIBRENMS_VERSION} https://github.com/librenms/librenms.git ${LIBRENMS_PATH} \
|
||||
&& COMPOSER_CACHE_DIR="/tmp" composer install --no-dev --no-interaction --no-ansi --working-dir=${LIBRENMS_PATH} \
|
||||
|
|
@ -118,8 +119,15 @@ RUN mkdir -p /opt \
|
|||
&& echo "foreach (glob(\"/data/config/*.php\") as \$filename) include \$filename;" >> ${LIBRENMS_PATH}/config.php \
|
||||
&& echo "foreach (glob(\"${LIBRENMS_PATH}/config.d/*.php\") as \$filename) include \$filename;" >> ${LIBRENMS_PATH}/config.php \
|
||||
&& pip3 install -r ${LIBRENMS_PATH}/requirements.txt \
|
||||
&& git clone https://github.com/librenms-plugins/Weathermap.git ${LIBRENMS_PATH}/html/plugins/Weathermap \
|
||||
&& chown -R nobody.nogroup ${LIBRENMS_PATH} \
|
||||
&& rm -rf ${LIBRENMS_PATH}/.git /tmp/*
|
||||
&& apk del build-dependencies \
|
||||
&& rm -rf /var/cache/apk/* \
|
||||
${LIBRENMS_PATH}/.git \
|
||||
${LIBRENMS_PATH}/html/plugins/Test \
|
||||
${LIBRENMS_PATH}/html/plugins/Weathermap/.git \
|
||||
${LIBRENMS_PATH}/html/plugins/Weathermap/configs \
|
||||
/tmp/*
|
||||
|
||||
COPY rootfs /
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ It's a fork of [CrazyMax's LibreNMS Docker image repository](https://github.com/
|
|||
* [Dispatcher service](doc/docker/environment-variables.md#dispatcher-service) or legacy [cron](doc/docker/environment-variables.md#cron-legacy) as "sidecar" containers
|
||||
* Syslog-ng support through a ["sidecar" container](doc/docker/environment-variables.md#syslog-ng)
|
||||
* Ability to configure [distributed polling](https://docs.librenms.org/Extensions/Distributed-Poller/)
|
||||
* Built-in LibreNMS [Weathermap plugin](https://docs.librenms.org/Extensions/Weathermap/)
|
||||
* Ability to add custom Monitoring plugins (Nagios)
|
||||
* OPCache enabled to store precompiled script bytecode in shared memory
|
||||
* [s6-overlay](https://github.com/just-containers/s6-overlay/) as process supervisor
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@
|
|||
### Misc
|
||||
|
||||
* `LIBRENMS_SNMP_COMMUNITY`: This container's SNMP v2c community string (default `librenmsdocker`)
|
||||
* `LIBRENMS_WEATHERMAP`: Enable LibreNMS [Weathermap plugin](https://docs.librenms.org/Extensions/Weathermap/) (default `false`)
|
||||
* `LIBRENMS_WEATHERMAP_SCHEDULE`: CRON expression format (default `*/5 * * * *`)
|
||||
* `MEMCACHED_HOST`: Hostname / IP address of a Memcached server
|
||||
* `MEMCACHED_PORT`: Port of the Memcached server (default `11211`)
|
||||
* `RRDCACHED_HOST`: Hostname / IP address of a RRDcached server
|
||||
|
|
|
|||
|
|
@ -24,3 +24,6 @@ MEMCACHED_HOST=memcached
|
|||
MEMCACHED_PORT=11211
|
||||
RRDCACHED_HOST=rrdcached
|
||||
RRDCACHED_PORT=42217
|
||||
|
||||
LIBRENMS_WEATHERMAP=false
|
||||
LIBRENMS_WEATHERMAP_SCHEDULE=*/5 * * * *
|
||||
|
|
|
|||
|
|
@ -26,3 +26,6 @@ LIBRENMS_SERVICE_UPDATE_FREQUENCY=86400
|
|||
|
||||
LIBRENMS_SERVICE_PING_ENABLED=false
|
||||
LIBRENMS_SERVICE_WATCHDOG_ENABLED=false
|
||||
|
||||
LIBRENMS_WEATHERMAP=false
|
||||
LIBRENMS_WEATHERMAP_SCHEDULE=*/5 * * * *
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ x-envlibrenms: &envlibrenms
|
|||
LIBRENMS_SERVICE_UPDATE_FREQUENCY: "86400"
|
||||
LIBRENMS_SERVICE_PING_ENABLED: "false"
|
||||
LIBRENMS_SERVICE_WATCHDOG_ENABLED: "false"
|
||||
LIBRENMS_WEATHERMAP: "true"
|
||||
LIBRENMS_WEATHERMAP_SCHEDULE: "*/5 * * * *"
|
||||
|
||||
services:
|
||||
db:
|
||||
|
|
|
|||
|
|
@ -26,3 +26,6 @@ LIBRENMS_SERVICE_UPDATE_FREQUENCY=86400
|
|||
|
||||
LIBRENMS_SERVICE_PING_ENABLED=false
|
||||
LIBRENMS_SERVICE_WATCHDOG_ENABLED=false
|
||||
|
||||
LIBRENMS_WEATHERMAP=false
|
||||
LIBRENMS_WEATHERMAP_SCHEDULE=*/5 * * * *
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@ sed -i -e "s/RANDOMSTRINGGOESHERE/${LIBRENMS_SNMP_COMMUNITY}/" /etc/snmp/snmpd.c
|
|||
|
||||
# Init files and folders
|
||||
echo "Initializing LibreNMS files / folders..."
|
||||
mkdir -p /data/config /data/logs /data/monitoring-plugins /data/rrd
|
||||
mkdir -p /data/config /data/logs /data/monitoring-plugins /data/rrd /data/weathermap
|
||||
ln -sf /data/weathermap ${LIBRENMS_PATH}/html/plugins/Weathermap/configs
|
||||
touch /data/logs/librenms.log
|
||||
rm -rf ${LIBRENMS_PATH}/logs
|
||||
rm -f ${LIBRENMS_PATH}/config.d/*
|
||||
|
|
@ -188,7 +189,7 @@ fi
|
|||
|
||||
# Fix perms
|
||||
echo "Fixing perms..."
|
||||
chown librenms. /data/config /data/monitoring-plugins /data/rrd
|
||||
chown librenms. /data/config /data/monitoring-plugins /data/rrd /data/weathermap
|
||||
chown -R librenms. /data/logs ${LIBRENMS_PATH}/config.d ${LIBRENMS_PATH}/bootstrap ${LIBRENMS_PATH}/logs ${LIBRENMS_PATH}/storage
|
||||
chmod ug+rw /data/logs /data/rrd ${LIBRENMS_PATH}/bootstrap/cache ${LIBRENMS_PATH}/storage ${LIBRENMS_PATH}/storage/framework/*
|
||||
|
||||
|
|
|
|||
38
rootfs/etc/cont-init.d/08-svc-weathermap.sh
Normal file
38
rootfs/etc/cont-init.d/08-svc-weathermap.sh
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
|
||||
CRONTAB_PATH="/var/spool/cron/crontabs"
|
||||
|
||||
LIBRENMS_WEATHERMAP=${LIBRENMS_WEATHERMAP:-false}
|
||||
LIBRENMS_WEATHERMAP_SCHEDULE=${LIBRENMS_WEATHERMAP_SCHEDULE:-*/5 * * * *}
|
||||
|
||||
SIDECAR_CRON=${SIDECAR_CRON:-0}
|
||||
SIDECAR_DISPATCHER=${SIDECAR_DISPATCHER:-0}
|
||||
SIDECAR_SYSLOGNG=${SIDECAR_SYSLOGNG:-0}
|
||||
|
||||
if [ "$SIDECAR_CRON" = "1" ] || [ "$SIDECAR_DISPATCHER" = "1" ] || [ "$SIDECAR_SYSLOGNG" = "1" ] || [ "$LIBRENMS_WEATHERMAP" != "true" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Init
|
||||
rm -rf ${CRONTAB_PATH}
|
||||
mkdir -m 0644 -p ${CRONTAB_PATH}
|
||||
touch ${CRONTAB_PATH}/librenms
|
||||
|
||||
# Cron
|
||||
if [ -n "$LIBRENMS_WEATHERMAP_SCHEDULE" ]; then
|
||||
echo "Creating LibreNMS Weathermap cron task with the following period fields: $LIBRENMS_WEATHERMAP_SCHEDULE"
|
||||
echo "${LIBRENMS_WEATHERMAP_SCHEDULE} php -f /opt/librenms/html/plugins/Weathermap/map-poller.php" >> ${CRONTAB_PATH}/librenms
|
||||
fi
|
||||
|
||||
# Fix perms
|
||||
echo "Fixing crontabs permissions..."
|
||||
chmod -R 0644 ${CRONTAB_PATH}
|
||||
|
||||
# Create service
|
||||
mkdir -p /etc/services.d/weathermap
|
||||
cat > /etc/services.d/weathermap/run <<EOL
|
||||
#!/usr/bin/execlineb -P
|
||||
with-contenv
|
||||
exec busybox crond -f -L /dev/stdout
|
||||
EOL
|
||||
chmod +x /etc/services.d/weathermap/run
|
||||
Loading…
Add table
Add a link
Reference in a new issue