Monday, March 18, 2019

Installing LibreNMS Docker image on Synology

At some point in time when you start having many devices in your home network, and you want to have some insight in things like bandwidth consumption, whether devices are alive, memory usage is ok... You have the need for a monitoring tool. I went for LibreNMS as it seemed user friendly with lots of features that are handy for a low-effort setup like auto-discovery. I went for the docker image from here. There are some excellent blogpost from other bloggers on how to setup this, but I ran into a few issues that I want to share with you. One issue that is still unresolved is running the web UI with https.


  1. Login to your NAS via SSH and make yourself root
  2. Follow the regular step by creating an APP_KEY in base64
  3. Create the MySQL user and database
  4. CREATE DATABASE librenms;
    CREATE USER 'librenms'@'%' IDENTIFIED BY 'yourpassword';
    CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'yourpassword';
    GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'%';
    FLUSH PRIVILEGES;
  5. I could only start the container with the following command which does not make use of the UID, GID and SSL config. I choose TCP port 30080 as my Synology is already serving other things over TCP port 80.
  6. docker run \
     -d \
     -h librenms \
     -p 30080:80 \
     -e APP_KEY="base64:your-app-key" \
     -e DB_HOST=192.168.0.Y \
     -e DB_NAME=librenms \
     -e DB_USER=librenms \
        -e TZ=Europe/Amsterdam \
     -e DB_PASS=yourpassword \
     -e BASE_URL=http://192.168.0.X:30080 \
        -e POLLERS=16 \
     -v /volume1/docker/librenms/logs:/opt/librenms/logs \
     -v /volume1/docker/librenms/rrd:/opt/librenms/rrd \
     -v /volume1/docker/librenms/ssl:/opt/librenms/ssl:ro \
     --name librenms \
     jarischaefer/docker-librenms
  7. When the container is started, from the command line you can monitor the logs from the container.
  8. Find the container ID
  9. docker ps
  10. Monitor the logs using the container ID
  11. docker logs container-id
  12. I did see these errors, which seems related to this Docker setup issue explained at Stackoverflow.. As the Docker setup on Synology is somewhat custom and probably prone to errors when you change something, I decided to ignore this.
  13. setfacl: /opt/librenms/bootstrap/cache: Operation not supported
    setfacl: /opt/librenms/logs: Operation not supported
    setfacl: /opt/librenms/rrd: Operation not supported
    ...
    
  14. I also had to remove the UID and GID from the Docker command as this was giving me the following error:
  15. failed to acquire lock schema
  16. So the posted command to launch the Docker container under step 4 is the one that worked for me.
  17. Next, setup the database, create an admin account for your user and login to the container to edit the configuration.
  18. docker exec librenms setup_database
    docker exec librenms create_admin
    docker exec librenms php /opt/librenms/adduser.php admin admin 10 you@here.com
    docker exec -it librenms bash
    Edit the LibreNMS config:
    vi /opt/librenms/conf.d/custom.php
    Set the SNMP community tag:
    $config['snmp']['community'][] = "public";
    $config['nets'][] = '192.168.0.0/24';
    $config['discovery_by_ip'] = true;
    Scan for SNMP devices:
    /opt/librenms/snmp-scan.py -r 192.168.0.0/24
  19. Normally, you should be able now to login into the web UI on http://192.168.0.X:30080. (note the default username/password for LibreNMS is admin:admin)
  20. The next thing I want to do is to figure out how Nginx can help serve LibreNMS over HTTPS with a reverse proxy. The current issue is the fact that base_url is being used as an environmental variable, which is causing all URLs to be always rewritten back to HTTP. No, this is not the expected behaviour. :-)

No comments:

Post a Comment