mirror of
https://github.com/teddysun/across.git
synced 2025-01-19 06:19:35 +08:00
update display
This commit is contained in:
parent
e22ab569a6
commit
4dd8008978
41
bench.sh
41
bench.sh
@ -30,36 +30,37 @@ next() {
|
||||
printf "%-70s\n" "-" | sed 's/\s/-/g'
|
||||
}
|
||||
|
||||
display() {
|
||||
local nodeName=$1
|
||||
local ipaddress=$2
|
||||
local speedtest=$3
|
||||
if [ "${#nodeName}" -lt "8" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t\t\t\t${GREEN}${ipaddress}\t\t${RED}${speedtest}${PLAIN}"
|
||||
elif [ "${#nodeName}" -lt "13" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t\t\t${GREEN}${ipaddress}\t\t${RED}${speedtest}${PLAIN}"
|
||||
elif [ "${#nodeName}" -lt "24" -a "${#ipaddress}" -gt "13" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t\t${GREEN}${ipaddress}\t${RED}${speedtest}${PLAIN}"
|
||||
elif [ "${#nodeName}" -lt "24" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t\t${GREEN}${ipaddress}\t\t${RED}${speedtest}${PLAIN}"
|
||||
elif [ "${#nodeName}" -ge "24" -a "${#ipaddress}" -gt "13" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t${GREEN}${ipaddress}\t${RED}${speedtest}${PLAIN}"
|
||||
elif [ "${#nodeName}" -ge "24" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t${GREEN}${ipaddress}\t\t${RED}${speedtest}${PLAIN}"
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
if [ "${#nodeName}" -lt "8" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t\t\t\t${GREEN}${ipaddress}\t\t${RED}${speedtest}${PLAIN}"
|
||||
elif [ "${#nodeName}" -lt "13" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t\t\t${GREEN}${ipaddress}\t\t${RED}${speedtest}${PLAIN}"
|
||||
elif [ "${#nodeName}" -lt "24" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t\t${GREEN}${ipaddress}\t\t${RED}${speedtest}${PLAIN}"
|
||||
elif [ "${#nodeName}" -ge "24" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t${GREEN}${ipaddress}\t\t${RED}${speedtest}${PLAIN}"
|
||||
fi
|
||||
display ${nodeName} ${ipaddress} ${speedtest}
|
||||
}
|
||||
|
||||
speed_test_v6() {
|
||||
local speedtest=$(wget -6O /dev/null -T300 $1 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
|
||||
local ipaddress=$(ping6 -c1 -n `awk -F'/' '{print $3}' <<< $1` | awk -F'[()]' '{print $2;exit}')
|
||||
local nodeName=$2
|
||||
if [ "${#nodeName}" -lt "8" -a "${#ipaddress}" -eq "13" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t\t\t\t${GREEN}${ipaddress}\t\t${RED}${speedtest}${PLAIN}"
|
||||
elif [ "${#nodeName}" -lt "13" -a "${#ipaddress}" -eq "13" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t\t\t${GREEN}${ipaddress}\t\t${RED}${speedtest}${PLAIN}"
|
||||
elif [ "${#nodeName}" -lt "24" -a "${#ipaddress}" -eq "13" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t\t${GREEN}${ipaddress}\t\t${RED}${speedtest}${PLAIN}"
|
||||
elif [ "${#nodeName}" -lt "24" -a "${#ipaddress}" -gt "13" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t\t${GREEN}${ipaddress}\t${RED}${speedtest}${PLAIN}"
|
||||
elif [ "${#nodeName}" -ge "24" ]; then
|
||||
echo -e "${YELLOW}${nodeName}\t${GREEN}${ipaddress}\t${RED}${speedtest}${PLAIN}"
|
||||
fi
|
||||
display ${nodeName} ${ipaddress} ${speedtest}
|
||||
}
|
||||
|
||||
speed() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user