-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathboxs.sh
30 lines (26 loc) · 1.41 KB
/
boxs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env
# @Author: imxieke
# @Date: 2021-10-17 22:59:39
# @Last Modified by: imxieke
# @Last Modified time: 2021-10-17 23:27:42
speed_test_v4() {
local output=$(LANG=C wget -4O /dev/null -T300 $1 2>&1)
local speedtest=$(printf '%s' "$output" | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
local ipaddress=$(printf '%s' "$output" | awk -F'|' '/Connecting to .*\|([^\|]+)\|/ {print $2}')
local nodeName=$2
printf "${YELLOW}%-32s${GREEN}%-24s${RED}%-14s${PLAIN}\n" "${nodeName}" "${ipaddress}" "${speedtest}"
}
speed_test_v6() {
local output=$(LANG=C wget -6O /dev/null -T300 $1 2>&1)
local speedtest=$(printf '%s' "$output" | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
local ipaddress=$(printf '%s' "$output" | awk -F'|' '/Connecting to .*\|([^\|]+)\|/ {print $2}')
local nodeName=$2
printf "${YELLOW}%-32s${GREEN}%-24s${RED}%-14s${PLAIN}\n" "${nodeName}" "${ipaddress}" "${speedtest}"
}
speed_test() {
local speedtest=$(wget -4O /dev/null -T300 $1 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
local ipaddress=$(ping -c1 -n `awk -F'/' '{print $3}' <<< $1` | awk -F'[()]' '{print $2;exit}')
local nodeName=$2
printf "${YELLOW}%-32s${GREEN}%-24s${RED}%-14s${PLAIN}\n" "${nodeName}:" "${ipaddress}:" "${speedtest}"
}
speed_test 'https://dldir1.qq.com/weixin/mac/WeChatMac.dmg' 'CacheFly'