Sometimes it can be very useful to know exactly how much network bandwidth a particular host is using or how much traffic is being handled by a gateway. As a tool for taking a quick peek at network activity, I have yet to find a tool better than bwm-ng.
Bandwidth Monitor NG (or bwm-ng for short) is a simple network and disk bandwidth monitoring program which can be run from the console on Linux, BSD, and Solaris platforms. Various sensors are supported for the collection of statistics including /proc/net/dev, netstat, getifaddr, sysctl, kstat, /proc/diskstats /proc/partitions, IOKit, devstat and libstatgrab. Interfaces or devices can be black/white listed so that you only see the data of interest. Multiple output options are supported such as curses (text or graphical), plain text, CVS, and HTML.
Bwm-ng is very simple to compile and configure; I have compiled from source on both OpenBSD and Linux platforms without needing to download additional libraries or make changes to the code. Let’s take a quick look at compiling and running bwm-ng on an OpenBSD gateway:
First, download the latest version of its source from the Volker Gropp Web site. At the time of writing, the most recent release is bwm-ng-0.6.
Move in to your build directory and unpack the code:
# cd ~/build/
# tar –xzf ../ bwm-ng-0.6.tar.gz
# cd bwm-ng-0.6/
Before kicking off the configure script take a look at the options available:
I found that all of the default settings were fine apart from the man page location. I manually set this:
# ./configure --mandir=/usr/local/man/
Build the binaries:
Before installing we can test that bwm-ng will actually work. To do this, execute the compiled binary in the src directory:
# ./src/bwm-ng –o plain (use ctrl+c to exit)
If that worked okay, then go ahead and complete the installation:
# make install
# cp ./bwm-ng.conf-example /etc/bwm-ng.conf
If you wish to configure bwm-ng further, then edit the configuration file using the man page as a reference for permitted option values. You may find that this is unnecessary as bwm-ng shows pretty much all you need to see by default.
Now that the program is installed it can be launched in the same way as any other binary executable would be:
Assuming that you’re using the standard ‘curses’ output option, then the command keys you’ll need to use will be ‘a’, ‘t’ and ‘u’.
‘a’ - Toggle between all or selected interfaces (bwm-ng.conf)
‘t’ - Switch the type of reading displayed between rate, max (peak), sum (throughput since program launch), and my favourite, which is the 30 second average
‘u’ - Display bytes/bits/packets/errors
While bwm-ng is a very simple tool, it can be incredibly useful. I regularly use it to check up on the throughput of my main Internet gateway or spot-check the bandwidth being used by nagios to perform host/network checks. Obviously the uses of this program are limited, and for long-term monitoring and trend analysis, a more in-depth solution is required. I’m currently taking a look at Ntop and MRTG; it would be great to hear from people who have deployed and/or used one of these in a production environment. If you have -- then why not leave a comment and share your experiences.