Monitoring your monthly bandwidth usage
After getting my new USB modem and struggling to make it work on Ubuntu 10.04 beta (at that time), I wanted to monitor my monthly bandwidth usage. I was thinking at first to create my own shell script, but I was lucky enough to know about vnstat. it’s a simple package you can install simply using
sudo aptitude install vnstat
you can use vnstat to monitor any network interface you want using the following steps except that you will have to use the name of the network interface you want to monitor.
Now I will tell vnstat to watch my USB modems bandwidth usage by making it watch the ppp0 interface.
sudo vnstat -u -i ppp0
this will create a file in /var/lib/vnstat with the name of your interface, so this will create a file named ppp0.
Now, just start the vnstat service. you will do it this time manually, but It will start automatically every time you start your machine.
sudo service vnstat start
Your ppp0 interface is being monitored now and you will be able to see its statistics by running
sudo vnstat -i ppp0
The output will be something like that
Database updated: Fri Aug 13 01:08:03 2010
rx: 17.36 MiB tx: 2.79 MiB total: 20.15 MiB
monthly
rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
Aug '10 17.36 MiB | 2.79 MiB | 20.15 MiB | 0.16 kbit/s
------------------------+-------------+-------------+---------------
estimated 43 MiB | 5 MiB | 48 MiB |
daily
rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
yesterday 8.54 MiB | 1.73 MiB | 10.27 MiB | 0.97 kbit/s
today 8.82 MiB | 1.06 MiB | 9.88 MiB | 19.82 kbit/s
------------------------+-------------+-------------+---------------
estimated 169 MiB | 21 MiB | 190 MiB |
rx is your received data, while tx is your sent data, or you can just view the total.

Hi, I'm