Created
May 31, 2012 14:57
-
-
Save 2xyo/2843956 to your computer and use it in GitHub Desktop.
Realtime Bandwidth monitor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
clear | |
declare -i rxnow txnow txlast rxlast | |
while true | |
do | |
chain=`ifconfig $1|grep bytes` | |
rxnow=`echo $chain | cut -d ":" -f2 | cut -d " " -f1` | |
txnow=`echo $chain | cut -d ":" -f3 | cut -d " " -f1` | |
rxdelta=$((rxnow-rxlast)) | |
txdelta=$((txnow-txlast)) | |
rxk=$(echo "scale=2; $rxdelta/1024"|bc) | |
txk=$(echo "scale=2; $txdelta/1024"|bc) | |
rxm=$(echo "scale=2; $rxk/1024"|bc) | |
txm=$(echo "scale=2; $txk/1024"|bc) | |
echo -e "RX=$rxdelta B/s\t$rxk KB/s\t$rxm MB/s" | |
echo -e "TX=$txdelta B/s\t$txk KB/s\t$txm MB/s" | |
sleep 1 | |
txlast=$txnow | |
rxlast=$rxnow | |
clear | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment