Skip to content

Instantly share code, notes, and snippets.

@erdoukki
Forked from 2xyo/bandwidth.sh
Created July 27, 2020 19:26
Show Gist options
  • Select an option

  • Save erdoukki/cd75b8f9ac3e7bf79271f3be4965aa4e to your computer and use it in GitHub Desktop.

Select an option

Save erdoukki/cd75b8f9ac3e7bf79271f3be4965aa4e to your computer and use it in GitHub Desktop.
Realtime Bandwidth monitor
#!/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
@erdoukki
Copy link
Copy Markdown
Author

opkg update
opkg install bash bc
./bandwidth.sh wan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment