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.
If you have any use for it, on find any problems with the script, please comment below.
| # | By | Comment | Post Date | Likes |
|---|