VnStat PHP a graphical interface application for most famous console mode network logger utility called “vnstat“. This VnStat PHP is a graphical frontend to VnStat, to view and monitor network traffic bandwidth usage report in nicely graphical format. It display
IN and
OUT network traffic statistics in hourly, days, months or full summary.
VnStat PHP PrerequisitesYou need to install the following software packages on your system.
- VnStat : A command-line network bandwidth monitoring tool, must be installed, configured and should collect network bandwidth statistics.
- Apache : A Web Server to serve web pages.
- PHP 5 : A server-side scripting language for executing php scripts on the server.
- php-gd extension : A GD extension for serving graphic images.
Installing and Configuring VnStatVnstat is a third party tool and can be installed via enabling
epel repository. After enabling, we can install vnstat by:
# yum install vnstat
Vnstat maintains its own database to keep all network information. To create new database for network interface say "eth0", issue the following command. Make sure to replace interface name as per your requirements.
# vnstat -i etho0
Error: Unable to read database "/var/lib/vnstat/eth0".
Info: -> A new database has been created.
If you get above error, you can simply ignore about such error, because you are executing the command first time. So, its creates new database for eth0.
Now run following command to update all enabled databases
# vnstat -u -i eth0
Next, add a crontab that runs every 5min and update eth0 database to generate traffic statistics.
*/5 * * * * /usr/bin/vnstat -u >/dev/null 2>&1
Downloading VnStat PHP Frontend# cd /tmp
# wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz
# tar xvf vnstat_php_frontend-1.5.1.tar.gz
Installing VnStat PHP Frontend# cp -fr vnstat_php_frontend-1.5.1/ /var/www/html/vnstat
Configuring VnStat PHP FrontendMake following changes in the below file:
# vi /var/www/html/vnstat/config.php
Set your default Language:
// edit these to reflect your particular situation
$locale = 'en_US.UTF-8';
$language = 'en';
Define your network interfaces to be monitored.
// list of network interfaces monitored by vnStat
$iface_list = array('eth0', 'eth0:0');
You can set custom names for your network interfaces.
// optional names for interfaces
// if there's no name set for an interface then the interface identifier.
// will be displayed instead
$iface_title['eth0'] = 'Internal';
$iface_title['eth0:0'] = 'External';
Access VnStat PHP and View GraphsYou can see network graphs that shows you a summary of network bandwidth usage in hours, days and months as like in below screenshot.
http://localhost/vnstat/
OR
http://your-ip-address/vnstat/