alexandermarston / vnstat-dashboard

A responsive web UI to view network traffic statistics provided by vnStat (with support for version 2.x)
https://alexandermarston.github.io/vnstat-dashboard/
142 stars 60 forks source link

FIX: Provided docker-compose won't find vnstat binary #41

Closed DerBunman closed 4 years ago

DerBunman commented 4 years ago

Hey there,

I just installed your application using the provided docker-compose file. When starting it, it was displaying the following error:

Fatal error: Uncaught Exception: JSON is invalid in /var/www/html/includes/vnstat.php:60 Stack trace: #0 /var/www/html/includes/vnstat.php(44): vnStat->processVnstatData('') #1 /var/www/html/index.php(27): vnStat->__construct('x/usr/bin/vnsta...') #2 {main} thrown in /var/www/html/includes/vnstat.php on line 60

After some searching I found that your default config has this option set: $vnstat_bin_dir = '/usr/bin/vnstat';

But the docker-compose points to /usr/local/bin/vnstat.

So there are two possible fixes in my opinion: a) Update the config to /usr/local/bin/vnstat b) add apt-get install vnstat to the Dockerfile

I'd go for option b, because option a would break the default config for non-docker users and I am not sure what would happen, if the docker host uses different lib versions than the container. If you install vnstat via apt-get in the container, I would think, this is the best way.

So here is a pull request for option b.

Br DerBunman

alexandermarston commented 4 years ago

Thanks for your PR.

The vnstat-dashboard application is supposed to use the underlying systems vnStat binary to pull the data through. If you installed vnStat directly in the container then you wouldn't be able to see the network data for the underlying system.