Thursday, August 25, 2011

linux: vnstat rocks!

vnstat is a superb tool to monitor monthly bandwidth usage.

I get notified by my ISP when I hit my monthly download quota (25 GB) that my speed will now be reduced to 256 kbps. Sometimes I'm left wondering how the heck I hit 25 gigs of downloading. So I started looking for a tool on Ubuntu that would monitor my bandwidth usage and show me daily/weekly/monthly download totals.

Requirements: It should work silently and unobtrusively in the background, and it should start automatically on reboot like a daemon. It would be nice to have it display graphical graphs. Also nice to have it display realtime stats (e.g. current rx and tx speeds).

There are quite a few tools that I found: bandwidthd, bwmon, bwbar etc (complete list here: http://www.ubuntugeek.com/bandwidth-monitoring-tools-for-ubuntu-users.html).

I didn't try all of them, but the most popular (or the one that appears at the top of the google search results for "bandwidth monitor tool ubuntu") is bandwidthd, and I just didn't have the patience to get it to work. There's no user manual, no real how-to and I gave up quickly on it.

vnstat saved the day. It exactly meets my requirements. You don't need to install it from the tarball either (in fact, that didn't work too well for me, I kept getting post-install configuration errors), and if you're on ubuntu, vnstat is in the standard apt repositories.

vnStat is a console-based network traffic monitor for Linux and BSD that keeps a log of network traffic for the selected interface(s). It uses the network interface statistics provided by the kernel as information source. This means that vnStat won't actually be sniffing any traffic and also ensures light use of system resources.

 

[08:17:59] ~ $ vnstat -d

eth1 / daily
     day         rx      |     tx      |    total    |   avg. rate
------------------------+-------------+-------------+---------------
08/24/11 134.81 MiB | 7.24 MiB | 142.05 MiB | 13.47 kbit/s
08/25/11 84.21 MiB | 5.63 MiB | 89.85 MiB | 24.82 kbit/s
------------------------+-------------+-------------+---------------
estimated 244 MiB | 14 MiB | 258 MiB |

[08:18:04] ~ $ vnstat -s

                  rx      /      tx      /     total    /   estimated

eth1:
Aug '11 219.02 MiB / 12.88 MiB / 231.90 MiB / 293.00 MiB
yesterday 134.81 MiB / 7.24 MiB / 142.05 MiB
today 84.21 MiB / 5.63 MiB / 89.85 MiB / 258 MiB

 

1 comment:

Unknown said...

How do you get those green circles from vnstat? are you using some program that parses vnstat and draws them?