| Tutorial details | |
|---|---|
| Difficulty | Intermediate (rss) |
| Root privileges | Yes |
| Requirements | Apache 2.x+ / PHP 5.x+ CentOS/ SL / Fedora/ RHEL |
You can use a PHP fronted for vnStat called "vnStat php frontend". This script was created as vnstat is console mode only and the author wanted to make a nice report of the data collected by vnStat. You need to install the following software(s) on your server:
[a] Apache
[b] PHP 5
[c] php-gd extension
You can install all of the above softwares using the yum command:
# yum install httpd php php-gd
Configure httpd service as per your requirements:
# vi /etc/httpd/conf/httpd.conf
Turn on the httpd service:
# chkconfig httpd on
# service httpd start
# netstat -tulpn | grep :80
Download vnStat php frontend
Visit this url and grab the latest version using the wget command:
$ cd /tmp
$ wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz
Untar or extract the tarball (tar file) called vnstat_php_frontend-1.5.1.tar.gz, type:
$ tar xvf vnstat_php_frontend-1.5.1.tar.gz
Install vnStat php frontend
You need to install this frontend at the following location:
/var/www/html/vnstat/
Make a directory called /var/www/html/vnstat/ using mkdir command:
# mkdir -p /var/www/html/vnstat/
Copy files from /tmp/vnstat_php_frontend-1.5.1 to /var/www/html/vnstat using cp command, enter:
# cp -av /tmp/vnstat_php_frontend-1.5.1/* /var/www/html/vnstat
If you are using SELinux, restore file(s) default SELinux security contexts using restorecon command:
# restorecon -Rv /var/www/html/vnstat/
Configure vnStat php frontend
You need to edit /var/www/html/vnstat/config.php, enter:
# vi /var/www/html/vnstat/config.php
You need to edit this file to reflect your particular situation. First, set language to en:
$language = 'en';
I am monitoring eth0 and eth1. So list of network interfaces monitored by vnStat should be set using the following:
$iface_list = array('eth0', 'eth1');
You can set names for interfaces:
$iface_title['eth0'] = 'Internal'; $iface_title['eth1'] = 'External';
Save and close the file.
How do I view graphs?
Fire a web browser and type the url:
http://your-server-ip-address-here/vnstat/ http://localhost/vnstat/ http://server1.cyberciti.biz/vnstat/ http://192.168.1.100/vnstat/
Sample outputs:
Check out related media
This tutorial is also available in a video format:
(Video.01: Demo: Setup and use vnStat )
You should follow me on twitter here or grab rss feed to keep track of new changes.
This FAQ entry is 2 of 2 in the "vnStat Monitor and Log Network Traffic Tutorial" series. Keep reading the rest of the series:- Install vnStat Network Traffic Monitor To Keep a Log Of Daily Traffic
- View Vnstat Graphs Using PHP Web Interface Frontend
















{ 3 comments… read them below or add one }
Hi,
Thanks….
very nice article…
Nice tool for customers meetings :-)
This blog has great essence of technical knowledge. This is awesome. Thanx for penning down your experience. Thanx once again. I’ve been reading many web hosting blogs, web development blogs, but I believe this one stands tall.