Naveen Kumar (नवीन कुमार) (moebiuscurve) wrote,
Naveen Kumar (नवीन कुमार)
moebiuscurve

How I keep track of my bandwidth usage...

Since my current Internet Service Provider Reliance Communication has started cheating, I now keep an account of my bandwidth usage. Here's a script I use for every internet session:

-----------------------------------------------------------------------------------------
filename: netusage.sh
-----------------------------------------------------------------------------------------
#!/bin/sh

while(2>1)
do
date >>usage.txt
ifconfig ppp0|tail -n 2 >>usage.txt
ifconfig ppp0
if [ "$?" -ne "0" ]; then
cp usage.txt $( date | sed -e "s/://g" |sed -e "s/ //g").txt
rm usage.txt
break;
fi
sleep 180;
done
-----------------------------------------------------------------------------------------
It takes a sample of usage every 3 minutes and when you are done, dumps your usage for the session in some file with name such as "SunFeb5044143IST2012.txt". Later you can grep, cut and sum all of your usage from all of the files for a particular period.

And if you are interested in some graph of your usage pattern, you cane even do that using some kind of regression or time series.

Other better ways are welcome.
Subscribe

  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments