Skip to content

Instantly share code, notes, and snippets.

@lzjluzijie
Created April 21, 2018 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lzjluzijie/ea3f7862d9f30864a4e475d22bffc708 to your computer and use it in GitHub Desktop.
Save lzjluzijie/ea3f7862d9f30864a4e475d22bffc708 to your computer and use it in GitHub Desktop.
测速
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;36m'
PLAIN='\033[0m'
speed_test_v4() {
local speedtest=$(wget -4O /dev/null -T300 $1 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
local host=$(awk -F'/' '{print $3}' <<< $1)
local ipaddress=$(ping -c1 -n `awk -F':' '{print $1}' <<< ${host}` | awk -F'[()]' '{print $2;exit}')
local nodeName=$2
printf "${YELLOW}%-32s${GREEN}%-24s${RED}%-14s${PLAIN}\n" "${nodeName}" "${ipaddress}" "${speedtest}"
}
speed_test_v4 'http://www2.unicomtest.com:8080/download?size=104857600' '北京联通'
speed_test_v4 'http://211.95.17.50:8080/download?size=104857600' '上海联通'
speed_test_v4 'http://st1.bjtelecom.net:8080/download?size=104857600' '北京电信'
speed_test_v4 'http://gzspeedtest.com:8080/download?size=104857600' '广州电信'
speed_test_v4 'http://speedtest3.gd.chinamobile.com:8080/download?size=104857600' '深圳移动'
speed_test_v4 'http://speedtest.bmcc.com.cn:8080/download?size=104857600' '北京移动'
speed_test_v4 'http://speedtest.tokyo.linode.com/100MB-tokyo.bin' '东京Linode'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment