jasonacox / Powerwall-Dashboard

Grafana Monitoring Dashboard for Tesla Solar and Powerwall Systems
MIT License
270 stars 57 forks source link

Add filesystem check to verify.sh #365

Open jasonacox opened 9 months ago

jasonacox commented 9 months ago

Verify script is not checking for file system permission. Investigate possible options to have it help troubleshoot permission issues.

Originally posted by @bparruck in https://github.com/jasonacox/Powerwall-Dashboard/issues/362#issuecomment-1751774549

bparruck commented 9 months ago

@jasonacox It would use to check that all containers are coming up properly.

jasonacox commented 9 months ago

There is a "container running" check, but the issue is that the services that need to write to the disk (influxdb and grafana) appear to be "up" even if they can't modify the filesystem. I added a simple check for both to ensure they have write access to the folder they should own:

echo -e -n "${dim} - Filesystem (./$CONTAINER): "
rm -f ./grafana/WRITE
ERR=`docker exec -it grafana touch /var/lib/grafana/WRITE`
if [ -e "./grafana/WRITE" ]; then
    echo -e $GOOD
    rm -f ./grafana/WRITE
else
    echo -e "${alert}ERROR: Unable to write to filesystem - check permissions${normal}"
fi

UPDATE: I moved this test to the "container running" conditional to avoid generating noise (errors that are false since the container is down). You can git pull to get this verify.sh update.

BuongiornoTexas commented 9 months ago

@jasonacox - I suspect this is part of the long running issue around grafana running a non-root user id in the container, and expecting an appropriately mapped sub userid/groupid in the host space - which is often not there and is why the chmod +777 is needed to allow universal write access.

A long term fix would be to address this underlying problem of making sure that the grafana suid/guid in the user space are correct for the version of docker being run. It's on my long term backlog to look at, as it affects me each time I upgrade.