Created
December 28, 2018 06:47
-
-
Save benzBrake/f6d0c8e814fb78bdec07347d1e6b751e to your computer and use it in GitHub Desktop.
Get upload/download speed of network interface
This file contains hidden or 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
| LANG="" | |
| while true | |
| do | |
| up_time1=`ifconfig $1 | grep "bytes" | awk '{print $6}' | awk -F: '{print $2}'` | |
| down_time1=`ifconfig $1 | grep "bytes" | awk '{print $2}' | awk -F: '{print $2}'` | |
| sleep 1 | |
| clear | |
| up_time2=`ifconfig $1 | grep "bytes" | awk '{print $6}' | awk -F: '{print $2}'` | |
| down_time2=`ifconfig $1 | grep "bytes" | awk '{print $2}' | awk -F: '{print $2}'` | |
| up_time1=${up_time1} | |
| up_time2=${up_time2} | |
| down_time1=${down_time1} | |
| down_time2=${down_time2} | |
| up_time=`expr $up_time2 - $up_time1` | |
| down_time=`expr $down_time2 - $down_time1` | |
| up_time=`expr $up_time / 1024` | |
| down_time=`expr $down_time / 1024` | |
| echo Upload speed: $up_time kb/s | |
| echo Download speed: $down_time kb/s | |
| done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
bash speed.sh eth0