Skip navigation

Monthly bandwidth monitoring utility:
vnstat + PHP frontend

The commands in this HOWTO must be entered in the terminal:
Applications -> Accessories -> Terminal

Install vnstat:
sudo apt-get install vnstat

Start and test vnstat:
Note which interfaces are active on your PC.
vnstat -u -i eth0
vnstat -u -i eth1

Now you can generate text reports of your monthly bandwidth usage. I use eth1 in the following examples, but you may be using eth0 or both eth0 and eth1.

Daily bandwidth report.
vnstat -i eth1 -d

Hourly bandwidth report.
vnstat -i eth1 -h

Monthly bandwidth report.
vnstat -i eth1 -m

Real time speed report.
vnstat -i eth1 -l

Install ubuntu-tweak:

sudo gedit /etc/apt/sources.list

Add the following line to the end of the file (if the line doesn’t already exist).
deb intrepid main

Then update and install.
sudo apt-get update
sudo apt-get install ubuntu-tweak

Create a startup script for vnstat:
(eth0 is the device name for my wired connection and eth1 is the name for my wireless connection. Create a separate entry for each internet interface that you will be monitoring.)

Applications -> System Tools -> Ubuntu Tweak -> Startup -> Autostart -> Add
Name: vnstat eth1
Command: vnstat -u -i eth1
Comment: [blank]

If you find the above reports useful, then you are done. If you would like to generate pretty reports that you can bookmark in your browser, then continue further.

Install and start XAMPP or LAMP:

Download vnstat PHP frontend to your desktop and install:
cd ~/Desktop
tar xvfz vnstat_php_frontend*.tar.gz -C ~/public_html
cd ~/public_html/vnstat_php_frontend*
mv vnstat_php_frontend* vnstat_php_frontend
gedit config.php

Change lines 32, 39-41, 56:
$iface_list = array('eth0', 'eth1', 'sixxs');
$iface_title['eth0'] = 'Internal';
$iface_title['eth1'] = 'Internet';
$iface_title['sixxs'] = 'SixXS IPv6';
$vnstat_bin = '';

$iface_list = array('eth1');
// $iface_title['eth0'] = 'Internal';
$iface_title['eth1'] = 'Internet';
// $iface_title['sixxs'] = 'SixXS IPv6';
$vnstat_bin = '/usr/bin/vnstat';

or something similar depending on which internet interfaces you are using.
(See Start and test vnstat above.)
Save and close the file.

Open vnstat PHP frontend:


One Comment

  1. thanks. very useful info.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: