Giter Site home page Giter Site logo

alexandermarston / vnstat-dashboard Goto Github PK

View Code? Open in Web Editor NEW
142.0 10.0 60.0 76 KB

A responsive web UI to view network traffic statistics provided by vnStat (with support for version 2.x)

Home Page: https://alexandermarston.github.io/vnstat-dashboard/

PHP 49.54% CSS 4.82% Dockerfile 1.37% Smarty 44.27%
vnstat docker networking monitoring network-traffic-monitor traffic

vnstat-dashboard's Introduction

What is vnstat-dashboard?

This dashboard is an adaptation of vnstat-php-frontend by bjd using Bootstrap written in PHP. It provides the following:

  • Hourly Statistics Chart (using Google Charts)
  • Daily & Monthly Statistics Overview
  • Top 10 Day Statistics
  • Automatically populated interface selection

Run it with Docker

How to build it

$ docker build . -t amarston/vnstat-dashboard:latest

How to publish it

$ docker push amarston/vnstat-dashboard:latest

How to start it

$ docker run --name vnstat-dashboard -p 80:80 -v /usr/bin/vnstat:/usr/bin/vnstat -v /var/lib/vnstat:/var/lib/vnstat -d amarston/vnstat-dashboard:latest

How to stop it

$ docker stop vnstat-dashboard

Run it with Locally

How to run it

$ cp -rp app/ /var/www/html/vnstat/
$ cd /var/www/html/vnstat/
$ composer install

Licensing

Copyright (C) 2019 Alexander Marston ([email protected])

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

vnstat-dashboard's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vnstat-dashboard's Issues

errors

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('/usr/bin/vnstat') #2 {main} thrown in /var/www/html/includes/vnstat.php on line 60

Lots of warnings (PHP 7.2.27-1+0~20200123.34+debian9~1.gbp63c0bc)

[24-Jan-2020 18:13:43 Europe/Amsterdam] PHP Warning: Use of undefined constant sortingFunction - assumed 'sortingFunction' (this will throw an Error in a future version of PHP) in /var/www/vnstat/app/includes/vnstat.php on line 136
[24-Jan-2020 18:13:43 Europe/Amsterdam] PHP Notice: Undefined variable: i in /var/www/vnstat/app/includes/vnstat.php on line 162
[24-Jan-2020 18:13:43 Europe/Amsterdam] PHP Notice: Undefined variable: i in /var/www/vnstat/app/includes/vnstat.php on line 188
[24-Jan-2020 18:13:43 Europe/Amsterdam] PHP Notice: Undefined variable: i in /var/www/vnstat/app/includes/vnstat.php on line 104
[24-Jan-2020 18:13:43 Europe/Amsterdam] PHP Notice: Undefined variable: i in /var/www/vnstat/app/includes/vnstat.php on line 141
[24-Jan-2020 18:13:43 Europe/Amsterdam] PHP Notice: Undefined variable: i in /var/www/vnstat/app/includes/vnstat.php on line 173
[24-Jan-2020 18:13:43 Europe/Amsterdam] PHP Notice: Undefined variable: i in /var/www/vnstat/app/includes/vnstat.php on line 199

combined interface selections not possible

If you have multiple interfaces you want to monitor, but would like to also see a roll-up of them, vnstat can accept multiple interfaces linked with a + and provide a roll-up; but the + is the separator for GET arguments. Adding rawurlencode and decode allows it work just fine. I can provide a pull as needed, though it's a 3 line change ( decode on line 39, encode on 29 and 31 of index.php ).

Button Interface Selection does not work

The Button Interface Selection does not work.
Because that construction


{foreach from=$interface_list item=value}
                    <a class="dropdown-item" href="?i={$value}">{$value}</a>
{/foreach}

in templates/moduje_header.tpl does not work.
It is neither PHP nor Javascript. What does not mean?

possible to get a non google-charts alternative?

Sorry, I realise this could be quite a big ask but figured it was worth asking just in case.

Would it be possible to have a version of this without the dependancy on google-charts? Ideally one where we hosted the JS ourselves?

Thanks in advance for your time, this repo is super useful!

PHP Notice

The following notice is observed when running index.php.

PHP Notice: Undefined variable: i in /home/alex/code/vnstat-dashboard/vnstat.php on line 111

[alex@nexus vnstat-dashboard]$ php --version
PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

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

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

Projected traffic usage

Probably the most useful feature, IMHO, of bandwidth monitoring and graphing is a projection of usage per cycle (i.e. month -- am I going to blow my usage cap for this month at my current rate of usage?).

This unfortunately seems to be missing.

Is it a big deal to add?

lots of warnings with debian 8.11 and php 7.2

Current PHP version: 7.2.16-1+020190307202206.17+jessie1.gbpa7be82
Debian GNU/Linux 8.11 (jessie)

when i enter the gui i get:

Notice: Undefined index: id in /var/www/vnstat/includes/vnstat.php on line 81
Notice: Undefined index: id in /var/www/vnstat/includes/vnstat.php on line 81
Notice: Undefined variable: typeAppend in /var/www/vnstat/includes/vnstat.php on line 118
Notice: Undefined variable: i in /var/www/vnstat/includes/vnstat.php on line 120
Warning: Use of undefined constant sortingFunction - assumed 'sortingFunction' (this will throw an Error in a future version of PHP) in /var/www/vnstat/includes/vnstat.php on line 136
Notice: Undefined variable: typeAppend in /var/www/vnstat/includes/vnstat.php on line 160
Notice: Undefined variable: i in /var/www/vnstat/includes/vnstat.php on line 162
Notice: Undefined variable: typeAppend in /var/www/vnstat/includes/vnstat.php on line 186
Notice: Undefined variable: i in /var/www/vnstat/includes/vnstat.php on line 188
Notice: Undefined variable: typeAppend in /var/www/vnstat/includes/vnstat.php on line 102
Notice: Undefined variable: i in /var/www/vnstat/includes/vnstat.php on line 104
Notice: Undefined variable: typeAppend in /var/www/vnstat/includes/vnstat.php on line 139
Notice: Undefined variable: i in /var/www/vnstat/includes/vnstat.php on line 141
Notice: Undefined variable: typeAppend in /var/www/vnstat/includes/vnstat.php on line 171
Notice: Undefined variable: i in /var/www/vnstat/includes/vnstat.php on line 173
Notice: Undefined variable: typeAppend in /var/www/vnstat/includes/vnstat.php on line 197
Notice: Undefined variable: i in /var/www/vnstat/includes/vnstat.php on line 199

and then, te graphic appears...
screenshot below

imagen

Warning in /includes/vnstat.php on line 136

There is warning as below:

Warning: Use of undefined constant sortingFunction - assumed 'sortingFunction' (this will throw an Error in a future version of PHP) in /var/www/html/vnstat2/includes/vnstat.php on line 136

I have fixed it using apostrophes around 'sortingFunction'.
But I am not sure if I am right.
And I am anxious about the "this will throw an Error in a future version of PHP".

[Question] Is RaspberryPi / Raspbian Buster supported ?

Shall the dashboard be available as container running on Raspberry / arm ?

Raspberry 4
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
Docker version 19.03.5, build 633a0ea

Log
standard_init_linux.go:211: exec user process caused "exec format error"

interface names under title should reflect config.php

If I define friendly names for interfaces in config.php, the page main title shows that name in brackets, but the interface names below -- the clickable links, still show the raw names. They should show the friendly names.

Refactor Code

The PHP code behind this project could use with some refactoring.

This issue is open for any PRs to improve code quality.

fopen is disabled for security reasons

I would love to use your dashboard, but fopen is disabled for security reasons on my server. If you come up with an alternative, please do let me know! I will not be enabling fopen.

missing links

the following links are missing:

  • hyperlink to a copy of the licence
  • hyperlink to the project page

Run vnstat-dashboard locally?

Hi,
I'm trying running vnstat-dashboard locally on my Ubuntu 10.20 machine.
Unfortunately I have an issue:

ela@akacja:/var/www/vnstat$ composer install
Composer could not find a composer.json file in /var/www/vnstat
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section

So I use command line installation from https://getcomposer.org/download/:

ela@akacja:/var/www/vnstat$ sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ela@akacja:/var/www/vnstat$ sudo php -r "if (hash_file('sha384', 'composer-setup.php') === 'c31c1e292ad7be5f49291169c0ac8f683499edddcfd4e42232982d0fd193004208a58ff6f353fde0012d35fdd72bc394') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installer verified
ela@akacja:/var/www/vnstat$ sudo php composer-setup.php
All settings correct for using Composer
Downloading...

Composer (version 2.0.4) successfully installed to: /var/www/vnstat/composer.phar
Use it: php composer.phar

ela@akacja:/var/www/vnstat$ sudo php -r "unlink('composer-setup.php');"
ela@akacja:/var/www/vnstat$

But after that when I run 'composer install' still receive: 'Composer could not find a composer.json file in /var/www/vnstat'
What should I do to move on?
Thanks in advance.

PHP 7.2 support

Hi,

Does this vnstat dashboard work with PHP 7.2? I tried to set it up and I am getting countless lines like the below:

PHP message: PHP Notice:  Undefined offset: 2765375 in /home/user/vnstat-dashboard/vnstat.php on line 33
PHP message: PHP Notice:  Undefined offset: 2765376 in /home/user/vnstat-dashboard/vnstat.php on line 33
PHP message: PHP Notice:  Undefined offset: 2765377 in /home/user/vnstat-dashboard/vnstat.php on line 33
PHP message: PHP Notice:  Undefined offset: 2765378 in /home/user/vnstat-dashboard/vnstat.php on line 33

Please let me know.
Thanks

No Data Displayed on Web UI

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}]}}]}

No data displayed with vnStat2.1

The project works fine until some time after my system upgrade. I checked the upgrade history seems it could be caused by the big version upgrade. Since poor on logging (seems) I have no idea how to report this issue in detail but let you know my guess. (P.S. Now I tasted the pain of bleeding-edge as an Arch Linux user ....)

Require hourly values

Hello Alex,

Can you please check the possibilities of adding Tab for hourly statistics that will show values like day or monthly

Hourly Statistics are in the wrong order

The hourly statistics shown in both the table as well as the graph are in the wrong order, with the oldest entry appearing first when it should appear last.

This should be corrected so the newest entry is shown first.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.