Jan 272011

Recently, I needed the ability to get a readout of the average bandwidth used on the server at one time. As many of you probably know, bandwidth is tough to measure for an instant. I could not find a tool or command that would allow me to get the data I wanted. So I decided to write one.

I write a perl script that uses the output from one invocation of ifconfig with a later invocation. The results are compared, and the total transferred, along with the average bps is extracted and printed.

Here is an example of printout:

thomas@thomas-desktop:~$ perl bandwidth-checker.pl -p -i=eth0 -t=5
Monitored traffic on interface eth0 for 5 seconds:
Incoming: 17.7109375 kbit (2.2138671875 KB) Average: 3.5421875 kbps (0.4427734375 KBps)
Outgoing: 2.109375 kbit (0.263671875 KB) Average: 0.421875 kbps (0.052734375 KBps)

I wrote a little page on the script, and have the source there as well. Hopefully it will help someone else out there: http://wiki.cornempire.net/scripts/bandwidth

If you have any use for it, on find any problems with the script, please comment below.

  One Response to “Bandwidth Checker Perl Script”

  1. Wow!
    This script was perfect for the little job I had.
    Thanks so much for a great utility!

    Paul E

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>