bjd / vnstat-php-frontend Goto Github PK
View Code? Open in Web Editor NEWPHP frontend for vnStat network traffic monitor
Home Page: http://www.sqweek.com
License: Other
PHP frontend for vnStat network traffic monitor
Home Page: http://www.sqweek.com
License: Other
0. WHAT IS IT? This is a PHP frontend end to vnstat, a network traffic logger. Since vnstat is console mode only I created this script to make a 'nice' report of the data collected by vnstat. For more information about vnstat check out http://humdi.net/vnstat/ For updates to this script check http://www.sqweek.com 1. REQUIREMENTS - vnstat setup and collecting data - webserver with PHP - php-gd extension installed for PNG graphs 2. INSTALL Installation should be really straightforward: Put the files from this package somewhere inside the webroot of your webserver. Then edit the few configuration options in config.php to suit your situation and your good to go. The various options are explained in config.php. 3. LICENSE vnstat PHP frontend 1.5.2 Copyright (c)2006-2011 Bjorge Dijkstra ([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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA NOTE: The Truetype font file VeraBd.ttf is copyright by Bitstream Inc. See vera_copyright.txt for more information.
I have just followed these instructions:
http://www.4geeksfromnet.com/2009/04/graphical-bandwidth-monitor-for-ubuntu.html
I apologize if this is out of date. Rather than setting up a of cron job to create the data files for each interface, why not do it from a single php script and run it from either cron or index.php. Cron is probably the better option.
This feels a lot neater and requires only needs one script to be run by cron. The $data_dir obviously needs to be writable by the web server.
I'd recommend creating a file called "run.php" with the following contents:
<?php
require_once("config.php");
for($i = 0; $i < count($iface_list); $i++){
$vnstat_bin." --dumpdb -i ".$iface_list[$i]." > ".$data_dir."/vnstat_dump_".$iface_list[$i];
}
?>
The cron service now need only run: "wget http://localhost/vnstat/run.php"
Adding
require_once('run.php');
to index.php, the system will always be showing the most up to date information and cron is not even needed. (Probably not great for production systems)
Hello,
I'm not sure how much are you maintaining this project.
vnstat from version 2.0 doesn't support command vnstat --dumpdb
as it is currently required for your frontend to fill the data from vnstat.
Here is the ticket and suggestion from vnstat
maintainer: vergoh/vnstat#141
Seems that the best option would be using command:
vnstat --json
which exports data to json format and then to parse it properly.
What is your opinion?
I know, you may answer - "well, try to fix it yourself" . Maybe, not sure/not much time at the moment.
Thanks.
All the best,
Frank
I've followed every instruction here.
using vnstat 1.10
frontend 1.5.2
Hi.
I think variables "$vnstat_bin" and "data_dir" in config should be default commented (or ='').
In vnstat.php in function get_vnstat_data:
if (!isset($vnstat_bin) || $vnstat_bin == '')
should be inverted to:
if (isset($vnstat_bin) && $vnstat_bin != '')
(If we have set location of dump get data from file)
Hi team,
I just tried your vnstat PHP frontend and calling "php vnstat.php" from CLI failed with error in line 47 (T() undefined function).
What went wrong, pls ? My handling of the script, or something else ?
Thank you and kind regards
Michael
Can we do a live monitoring using the PHP front end?
Do you have a docker image for your php frontend?
I would like to see all data in KB (or MB) instead of "auto" b/kb/mb/gb. This allows me to see at a glance very large and very small values.
No svg graphs are shown, after digging into it, the svg contains a notice like
Notice: Array to string conversion in $webroot/vnstat/graph_svg.php on line 48
so as a quick workaround, these changes to the config.php file are helping, as long as this is not fixed
-error_reporting(E_ALL | E_NOTICE);
+error_reporting(E_ALL & ~E_NOTICE);
It looks like vnstat-php is trying to auto-detect the script's location and force all links to be under this root. This doesn't work if the location cannot be auto-detected (e.g. script is behind a reverse proxy).
I'm not actually sure if there's much point in the $script
variable, as there's non-dynamic references to graph_svg.php, for example (so some dynamic path detection isn't being used anyway). I suppose if you want to allow the user to rename index.php to something else, it may come in handy, in which case, using basename
on the $script
variable would be just as effective.
Thanks for the script!
Hi, love this vnstat interface!
I'd really like to see a "realtime" page to show vnstat data if it is running in live (-l) mode.
At the moment I can only see hourly, daily & monthly.
Thanks for reading!
Hi all,
Thank you for this great tool... But was wondering if you arent planning to upgrade the actual version using google charts... It is way better, more "shiny" and much beautiful :)
Thanks anyway :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.