Subscribe to UbuntuBuzz Telegram Channel to get article updates directly.
Required Info
You should know your network interface to be monitored. For example, I connect to the internet via WLAN (from my router) so I need the name of my WLAN interface. To know what interface currently enabled, use ifconfig:
$ ifconfig
wlp3s0b1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
The output above indicates that my interface for WLAN is wlp3s0b1. Note your own interface name.
1. Install Apache & PHP & PHP-GD
vnStat PHP requires 3 server-related programs to run: apache, php, and php-gd. To install them on Ubuntu 14.04, 16.04, 16.10, and later:
$ sudo apt-get install apache2 php7.0 php7.0-gd
2. Install vnstat Program
The vnstat program is available on repo. This is required by vnStat PHP.
$ sudo apt-get install vnstat
3. Configure vnstat.conf
Once vnstat installed, determine default network interface in /etc/vnstat.conf file. For example, I want to monitor my WLAN so I use wlp3s0b1 interface.
Interface "wlp3s0b1"
3. Download vnStat PHP Program
Current version of vnStat PHP is 1.5.1. Run this command and it should download the package into your $HOME directory.
$ wget -c http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz
4. Install vnStat PHP
Installing the vnStat PHP is extracting the package and move its directory into Apache public www directory.
$ tar xzf vnstat_php_frontend-1.5.1.tar.gz
$ sudo mv vnstat_php_frontend-1.5.1 /var/www/html/
5. Configure config.php
The last config is determining the network interface and user language in vnStat PHP config.php file. You can name the monitor too.
$language = 'en';
$iface_list = array('wlp3s0b1', 'enp0s29u1u4');
$iface_title['wlp3s0b1'] = 'MY WLAN';
6. Enjoy Web Panel
Now open your web browser and visit localhost page at vnstat directory. According to this tutorial, it should be http://localhost/vnstat_php_frontend-1.5.1/. Anytime you want to see your traffic data, visit that page.
Some Tips
- You can monitor more than one network interface (e.g. wlan, lan, usb tethering, etc.) by specifying them in config.php.
- You can rename the directory name to simpler one such as "vnstat/".
- You can bookmark the URL of your vnStat PHP panel.