Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No interface with vnstat 2.4 + Cannot read property 'getTime' of null #40

Open
Aerya opened this issue Sep 14, 2019 · 5 comments
Open
Assignees
Labels

Comments

@Aerya
Copy link

Aerya commented Sep 14, 2019

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
Copy link
Owner

@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
Copy link

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

@tomangert
Copy link

"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
Copy link

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
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants