CentOS / RHEL: View Vnstat Graphs Using PHP Web Interface Frontend

How do Install view vnstat – a network console output using my web-browser? How do I install vnstat php frontend on CentOS / RHEL / Fedora Linux based system?

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

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:
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:


Sample outputs:

Fig.01: vnstat network summary graph

Fig.02: vnstart daily traffic graphs
Fig.03: vnstat monthly network traffic log

Check out related media

This tutorial is also available in a video format:

This entry is 2 of 3 in the vnStat Monitor and Log Network Traffic Tutorial series. Keep reading the rest of the series:
  1. How to install vnstat on a CentOS/RHEL/Fedora Linux
  2. View Vnstat Graphs Using PHP Web Interface Frontend
  3. How to install vnstat on FreeBSD Unix server

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


Start your Bitcoin Exchange with our Software

Start your Bitcoin Exchange with our Software Setup your white label bitcoin exchange right away. Or create your own cryptocurrency using...

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....