Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: VnStat - Web Based Interface for Network Monitoring  (Read 2258 times)

0 Members and 1 Guest are viewing this topic.

Vinil

  • Guest
VnStat - Web Based Interface for Network Monitoring
« on: January 16, 2014, 04:58:25 pm »
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 Prerequisites

You 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 VnStat

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

Quote
# 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

Code: [Select]
# vnstat -u -i eth0

Next, add a crontab that runs every 5min and update eth0 database to generate traffic statistics.

Quote
*/5 * * * * /usr/bin/vnstat -u >/dev/null 2>&1



Downloading VnStat PHP Frontend

Code: [Select]
# 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

Quote
# cp -fr vnstat_php_frontend-1.5.1/ /var/www/html/vnstat


Configuring VnStat PHP Frontend

Make following changes in the below file:

# vi /var/www/html/vnstat/config.php

Set your default Language:

Quote
// edit these to reflect your particular situation
$locale = 'en_US.UTF-8';
$language = 'en';

Define your network interfaces to be monitored.

Quote
// list of network interfaces monitored by vnStat
$iface_list = array('eth0', 'eth0:0');


You can set custom names for your network interfaces.

Quote
// 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 Graphs

You can see network graphs that shows you a summary of network bandwidth usage in hours, days and months as like in below screenshot.

Code: [Select]
http://localhost/vnstat/
OR
http://your-ip-address/vnstat/



« Last Edit: January 16, 2014, 05:06:25 pm by Vinil »