LibreNMS ./validate.sh – Some folders have incorrect file permissions, this may cause issues.

Helpful article here. https://wifitechtalk.com/librenms-permissions-error/

When running the following command,

sudo /opt/librenms/validate.sh

I’ve been getting the following errors.

[FAIL]  Some folders have incorrect file permissions, this may cause issues.
    [FIX]: 
    sudo chown -R librenms:librenms /opt/librenms
    sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
    sudo chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
    Files:
     /opt/librenms/storage/framework/views/adc52b677409cdba8d8e89dc

You can run the commands and fix the problem, but they pop up later and it does the same thing.

Create Script to fix permissions

Work around is to have a script run these commands every few minutes.

vi /root/librenms_fix_permissions.sh

Add the following

#!/bin/bash 
sudo chown -R librenms:librenms /opt/librenms 
sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/ 
sudo chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

Make the script executable

sudo chmod +x librenms_fix_permissions.sh

Add to Crontab

sudo crontab -e 

Add the following entry to Cron to run every 30 minutes

*/30 * * * * /root/librenms_fix_permissions.sh

How to Setup a Cron Job

There are a couple ways to set up a cron job.  If you have a script that you want to run ever so often, you could drop it in one of the cron directories, like cron.daily, or cron.weekly.  These are located in /etc.  Another way to do it is to use crontab.

To setup a cron job in crontab type

crontab -e

and then,

*/30 * * * * /path/to/yourscript.sh

The “*/30”  makes the script run every 30 minutes.  Below gives you a better idea of how the line works.  The asterisk (*) specifies all possible values for a field, but can/should be replaced with the time you want the script to execute.

* * * * * command to be executed

*(min) *(hr) *(DoM) *(month) *(week) /path/to/command_or_script.sh
  • min= Minute 0 – 50
  • hr = Hour 0-59
  • DoM = Day of month 0-31
  • month = Month 1-12
  • week = Day of Week 0-7, Sunday is 0 or 7

Below are a couple of examples of how to run a script or command.
Every minute.

* * * * * /path/to/script.sh

Every day 10 minutes after 1 in the morning,

10 1 * * * /path/to/command

Also, if you don’t want to be emailed the output of the command, you can simple append “>/dev/null 2>&1” to the end of the crontab line.
Example

0 * 1 * * /path/to/command/ >/dev/null 2>&1