Skip navigation

Category Archives: Bandwidth Monitor

Monthly bandwidth monitoring utility:
vnstat + PHP frontend
http://humdi.net/vnstat/
http://www.sqweek.com/sqweek/index.php?p=1

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:
http://ubuntu-tweak.com/downloads

sudo gedit /etc/apt/sources.list

Add the following line to the end of the file (if the line doesn’t already exist).
deb http://ppa.launchpad.net/tualatrix/ubuntu 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:
https://humanlanguage.wordpress.com/2006/12/03/install-xampp-on-ubuntu/
https://humanlanguage.wordpress.com/2006/12/03/install-lamp-on-ubuntu/

Download vnstat PHP frontend to your desktop and install:
cd ~/Desktop
wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.4.1.tar.gz
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 = '';

to:
$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:
http://localhost/username/vnstat_php_frontend