Skip to content

Commit

Permalink
Handle LibreNMS plugins (#175)
Browse files Browse the repository at this point in the history
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max and crazy-max authored Mar 10, 2021
1 parent cddc5e9 commit 96c67e9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 21.2.0-r2 (2021/03/10)

* Handle LibreNMS plugins (#171)

## 21.2.0-r1 (2021/03/04)

* Switch to `yasu`
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Image: librenms/librenms:latest
* [LNMS command](doc/notes/lnms-command.md)
* [Validate](doc/notes/validate.md)
* [Dispatcher service](doc/notes/dispatcher-service.md)
* [Add a LibreNMS plugin](doc/notes/plugins.md)
* [Syslog-ng](doc/notes/syslog-ng.md)
* [Additional Monitoring plugins (Nagios)](doc/notes/additional-monitoring-plugins.md)
* [Custom alert templates](doc/notes/alert-templates.md)
Expand Down
5 changes: 3 additions & 2 deletions doc/docker/volumes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Volumes

* `/data`: Contains configuration, rrd database, logs, additional Monitoring plugins, additional syslog-ng config files
* `/data`: Contains configuration, plugins, rrd database, logs, additional Monitoring plugins, additional syslog-ng config files

> :warning: Note that the volume should be owned by the user/group with the specified `PUID` and `PGID`. If you don't give the volume correct permissions, the container may not start.
> :warning: Note that the volume should be owned by the user/group with the specified `PUID` and `PGID`. If you don't
> give the volume correct permissions, the container may not start.
6 changes: 6 additions & 0 deletions doc/notes/plugins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Add a LibreNMS plugin

You can add [plugins for LibreNMS](https://docs.librenms.org/Extensions/Plugin-System/) in `/data/plugins/`. If you
add a plugin that already exists in LibreNMS, it will be removed and yours will be used (except for Weathermap).

> ⚠️ Container has to be restarted to propagate changes
20 changes: 18 additions & 2 deletions rootfs/etc/cont-init.d/03-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ 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 /data/weathermap /data/alert-templates
mkdir -p /data/config /data/logs /data/monitoring-plugins /data/plugins /data/rrd /data/weathermap /data/alert-templates
ln -sf /data/weathermap ${LIBRENMS_PATH}/html/plugins/Weathermap/configs
touch /data/logs/librenms.log
rm -rf ${LIBRENMS_PATH}/logs
Expand Down Expand Up @@ -185,9 +185,25 @@ cat > ${LIBRENMS_PATH}/config.d/dispatcher.php <<EOL
\$config['service_watchdog_enabled'] = false;
EOL

# Check plugins
echo "Checking LibreNMS plugins..."
plugins=$(ls -l /data/plugins | egrep '^d' | awk '{print $9}')
for plugin in ${plugins}; do
if [ "${plugin}" == "Weathermap" ]; then
echo " WARNING: Plugin Weathermap cannot be overriden. Skipping..."
continue
fi
echo " Linking plugin ${plugin}..."
if [ -d "${LIBRENMS_PATH}/html/plugins/${plugin}" ]; then
rm -rf "${LIBRENMS_PATH}/html/plugins/${plugin}"
fi
ln -sf "/data/plugins/${plugin}" "${LIBRENMS_PATH}/html/plugins/${plugin}"
chown -h librenms. "${LIBRENMS_PATH}/html/plugins/${plugin}"
done

# Fix perms
echo "Fixing perms..."
chown librenms. /data/config /data/monitoring-plugins /data/rrd /data/weathermap /data/alert-templates
chown librenms. /data/config /data/monitoring-plugins /data/plugins /data/rrd /data/weathermap /data/alert-templates
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/*

Expand Down

0 comments on commit 96c67e9

Please sign in to comment.