update display

This commit is contained in:
Teddysun 2016-12-01 18:29:17 +09:00 committed by GitHub
parent e22ab569a6
commit 4dd8008978

View File

@ -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() {