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

No Data Displayed on Web UI #33

Closed JGPorteous closed 5 years ago

JGPorteous commented 5 years ago

Good day,

I've setup vnstat-dashboard and I'm not getting any data on the WEB UI.

vnstat is collecting data, vnstat version 1.15 I'm not using Docker, installed to apache2 /var/www/html/vnstat

Errors found in /var/log/apache2/errors.log :

PHP Warning:  Invalid argument supplied for foreach() in /var/www/html/vnstat-dashboard/vnstat.php on line 170
PHP Notice:  Undefined index: top in /var/www/html/vnstat-dashboard/vnstat.php on line 115
PHP Warning:  Invalid argument supplied for foreach() in /var/www/html/vnstat-dashboard/vnstat.php on line 115
PHP Notice:  Undefined index: day in /var/www/html/vnstat-dashboard/vnstat.php on line 128
PHP Warning:  Invalid argument supplied for foreach() in /var/www/html/vnstat-dashboard/vnstat.php on line 128
PHP Notice:  Undefined index: hour in /var/www/html/vnstat-dashboard/vnstat.php on line 148
PHP Warning:  Invalid argument supplied for foreach() in /var/www/html/vnstat-dashboard/vnstat.php on line 148
PHP Warning:  asort() expects parameter 1 to be array, null given in /var/www/html/vnstat-dashboard/vnstat.php on line 167

Config:

// Set the default system Timezone
date_default_timezone_set('Africa/Johannesburg');

// Path of vnstat
$vnstat_bin_dir = '/usr/bin/vnstat';

// Set to true to set your own interfaces
$use_predefined_interfaces = true;

if ($use_predefined_interfaces == true) {
    $interface_list = ["eth0","wlan0"];

    $interface_name['eth0'] = "Ethernet";
    $interface_name['wlan0'] = "WiFi";
} else {
    $interface_list = getVnstatInterfaces($vnstat_bin_dir);

    foreach ($interface_list as $interface) {
        $interface_name[$interface] = $interface;
    }
}

vnstat --json -i eth0 : {"vnstatversion":"1.15","jsonversion":"1","interfaces":[{"id":"eth0","nick":"eth0","created":{"date":{"year":2019,"month":6,"day":15}},"updated":{"date":{"year":2019,"month":6,"day":15},"time":{"hour":10,"minutes":5}},"traffic":{"total":{"rx":14955,"tx":74990},"days":[{"id":0,"date":{"year":2019,"month":6,"day":15},"rx":14955,"tx":74990}],"months":[{"id":0,"date":{"year":2019,"month":6},"rx":14955,"tx":74990}],"tops":[],"hours":[{"id":8,"date":{"year":2019,"month":6,"day":15},"rx":8147,"tx":14558},{"id":9,"date":{"year":2019,"month":6,"day":15},"rx":6659,"tx":57536},{"id":10,"date":{"year":2019,"month":6,"day":15},"rx":149,"tx":2896}]}}]}

extremeCrazyCoder commented 5 years ago

The current version of Master branch is only compatible with vnstat >= 2.0 I think (see #25)

Use a commit befor the merge of that PR and it should work (should be dc2a299a76382c50cbc92fb2e2ac150c8e0b2b3c)

JGPorteous commented 5 years ago

Thank you so much, upgraded vnstat to 2.2 and it's working.