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 interface with vnstat 2.4 + Cannot read property 'getTime' of null #40

Open Aerya opened 5 years ago

Aerya commented 5 years ago

hi,

Using your Docker. Vnstat compiled from sources: vnStat 2.4 by Teemu Toivola Here's my config file: // Disable error reporting to screen /ini_set('display_errors', 0); error_reporting(E_ALL);/

// Set the default system Timezone date_default_timezone_set('Europe/Paris');

// 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 = ["enp3s0", "veth031f9b8", "vethada0f5f"];

$interface_name['enp3s0'] = "1";
$interface_name['veth031f9b8'] = "2";
$interface_name['vethada0f5f'] = "3";

}

I have no interface to select in the WebUI.

Thanks

alexandermarston commented 4 years ago

@Aerya thanks for submitting this issue.

Could you please run "vnstat --json" on your system and attach the results to this issue and I can look into this for you.

Many thanks, Alex

tomangert commented 4 years ago

vnstat2.x uses a different json tag for interface names. ('name' instead of 'id') The pull request for #35 also adds vnstat2 support.

tomangert commented 4 years ago

"interfaces": [ { "name": "br0", "alias": "", "created": { "date": { "year": 2019, "month": 6, "day": 25 } }, "updated": { "date": { "year": 2019, "month": 10, "day": 11 }, "time": { "hour": 9, "minute": 5 } }, "traffic": { "total": { "rx": 1378209818161, "tx": 723392017482 }, ...

qwrty-ftw commented 4 years ago

I have got the same issue (vnstat 2.6)

image

My config.php

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

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

    $interface_name['eth0'] = "Internal #1";
    $interface_name['eth1'] = "Internal #2";
    $interface_name['tun0'] = "VPN Tunnel";
}
edwardecl commented 3 years ago

The other guy on here who said that 'id' has been changed to 'name' is correct, you just need to modify 2 lines in the file...

/vnstat/includes/vnstat.php

line 81: array_push($vnstatInterfaces, $interface['name']);

Line 98: $arrayIndex = array_search($interface, array_column($this->vnstatData['interfaces'], 'name'));

And it works on vnstat 2.6 (Ubuntu 20.10).