Cool bandwidth monitoring script

  bash, linux, raspberry-pi
#!/bin/bash
if [ -z "$1" ]; then
        echo
        echo usage: $0 network-interface [delay in seconds]
        echo
        echo e.g. $0 eth0
        echo e.g. $0 wlan0 30
        echo
        exit
fi
if [ -z "$2" ]; then
  DELAY=5
  echo "Using default, showing bandwidth usage every $DELAY seconds"
else
  DELAY=1
fi
IF=$1
while true
do
        R1=`cat /sys/class/net/$1/statistics/rx_bytes`
        T1=`cat /sys/class/net/$1/statistics/tx_bytes`
        sleep $DELAY
        R2=`cat /sys/class/net/$1/statistics/rx_bytes`
        T2=`cat /sys/class/net/$1/statistics/tx_bytes`
        TBPS=`expr $T2 - $T1`
        RBPS=`expr $R2 - $R1`
        TKBPS=`expr $TBPS / 1024`
        RKBPS=`expr $RBPS / 1024`
        echo "tx $1: $TKBPS kb/s rx $1: $RKBPS kb/s"
done

Example test: place a large file at your-domain/file.bin

# use wget to grab the file, redirect to dev null:
while true; do wget -qO- http://your-domain/file.bin &> /dev/null; sleep 0; done

or

#!/bin/bash
# use wget to grab the file, redirect to dev null:
COUNTER=0
while true; do
  echo "Run #$COUNTER at `date`"
  wget -qO- http://192.168.1.50/test/a &> /dev/null;
  sleep 0;
  let COUNTER=COUNTER+1
done