Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ -z "$1" ]; then
- echo
- echo usage: $0 network-interface
- echo
- echo e.g. $0 eth0
- echo
- exit
- fi
- interface=$1
- while true
- do
- r1=`cat /sys/class/net/$interface/statistics/rx_bytes`
- t1=`cat /sys/class/net/$interface/statistics/tx_bytes`
- sleep 1
- r2=`cat /sys/class/net/$interface/statistics/rx_bytes`
- t2=`cat /sys/class/net/$interface/statistics/tx_bytes`
- tbps=`expr $T2 - $T1`
- rbps=`expr $R2 - $R1`
- tkbps=`expr $tbps / 1024`
- rkbps=`expr $rbps / 1024`
- echo "tx $interface: $tkbps kb/s rx $interface: $rkbps kb/s"
- done
Add Comment
Please, Sign In to add comment