Well, I was bored yesterday and I came up with this:
getdata() {
DATA=`ifconfig eth0|sed -n 's/\( *RX bytes:\)\([0-9]*\)\([^:]*\):\([0-9]*\)\(.*)\)/\2 \4/p'`
RX=`echo $DATA|sed -n 's/\([0-9]*\) \(.*\)/\1/p'`
TX=`echo $DATA|sed -n 's/\([^ ]*\) \(.*\)/\2/p'`
}
getdata
while true; do
OLDRX=$RX
OLDTX=$TX
getdata
echo -n -e "\fRX: $((RX-OLDRX)) B/s\nTX: $((TX-OLDTX)) B/s"
sleep 1
done
What it does is call ifconfig eth0 every second, and compare the total number of bytes received and transmitted up to the previous second, with the number up to this second. The difference is, well, the number of bytes transferred this second. It’s a cheap network usage monitor.