bandwidth monitor 1.4
bandwidth monitor is a small application which polls /proc/net/dev for the byte counts for a given network device.
This program started as a shell script that I ran on my home-brew firewall wireless router (Linux, of course, on a 486/66) to keep track of my incoming and outgoing bandwidth. This let me know that I was getting the bandwidth that I paid for, and it also helped me keep an eye on the throttling of bulk traffic so that I didn't choke out my interactive sessions. Of course, that was before I had QOS.
The program is probably tied to Linux, since it grabs the byte counts for the requested interface right from /proc/net/dev. It could pretty easily be modified to grab the same information from the output of /sbin/ifconfig, but that would waste resources to spawn a new process to parse the /proc/net/dev file and regurgitate it to us. Also, I haven't bothered to look at how uniform the output of the byte counts from /sbin/ifconfig is on other operating systems.
As a side note, the C version also uses nanosleep() and gettimeofday() to get more accurate polling intervals and track the overall time (since sleep(), usleep(), nanosleep(), et. al. only guaruntee to wait at least as long as you request, but do not guaruntee that it won't be possibly much longer...) So, if you were interested in porting it, you'd have to make sure that nanosleep() and gettimeofday() were also available, or lose the resolution of the time used in bandwidth calculations.
$ gcc -O3 -o bandwidth_monitor bandwidth_monitor.c