Monitoring bandwidth with bwm-ng · Tuesday October 7, 2008 by Rudolf Vavruch
I discovered how to watch the bandwidth of server today using a tool called bwm-ng. It’s in the Ubuntu Hardy repos, you can install with the following command:
sudo aptitude install bwm-ngWhen you run it in a terminal without parameters, it displays a running update of how much bandwidth is being used. This makes it a handy tool to get an immediate idea of what your network traffic is like, and there are also options to examine disk IO. Besides the “live running commentary” mode, it can also output in other forms as well, for example CSV.
To create a poor man’s ntop, i.e. generate a log file of a servers bandwidth throughput over time; I wrote a script that is cronned every minute, the interesting part looks like this:
bwm-ng -o csv -c 6 -T rate -I eth0 >>bandwidth.log
Here‘s a run down of what the parameters do:
- -o csv
- Output to CSV format. Annoyingly you have to download the tarball from the site linked above to get the file which contains the legend for the CSV generated. Why not just include it in the
manpage? Being the considerate type I have included this information later in this post. - -c 6
- Print only 6 reads. Not 6 lines, but 6 reads of all the interfaces, including a total line.
- -T rate
- Type rate. Show only the rate, other options for this parameter are avg and max. Without this parameter the output also show amount of data and packets transferred.
- -I eth0
- Comma separated whitelist of interfaces to show. Can also be used to blacklist interfaces. Even with only one interface this still prints a total line.
This generates the something which looks like this:
1222420795;eth0;526.73;237.62;764.36;120;266;1.98;3.96;5.94;2;1;0.00;0.00;0;01222420795;total;526.73;237.62;764.36;120;266;1.98;3.96;5.94;2;1;0.00;0.00;0;0
And as promised the legend for the output:
unix_timestamp;iface_name;bytes_out;bytes_in;bytes_total;packets_out;packets_in;packets_total;errors_out;errors_in
All this data is then appended to a file called bandwidth.log ( >>bandwidth.log).
Commenting is closed for this article.
The Audi A4 banner & calling functions in Flash from JavaScript YSlow: Two page hits for the price of one!