Skip to content

Commit

Permalink
修改部分代码
Browse files Browse the repository at this point in the history
  • Loading branch information
linrong123 committed Aug 16, 2023
1 parent 3d81eb1 commit abd9616
Show file tree
Hide file tree
Showing 12 changed files with 3,104 additions and 75 deletions.
16 changes: 1 addition & 15 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ done

#默认参数
if [ "$_included_benchmarks" == "" ]; then
_included_benchmarks="io,bandwidth,download,traceroute,backtraceroute,allping"
_included_benchmarks="io,bandwidth,download,backtraceroute,unlock"
fi

_included_benchmarks="systeminfo,"${_included_benchmarks}
Expand Down Expand Up @@ -56,20 +56,6 @@ do
eval ${i}
done


#上传文件
updatefile()
{
resultstr=$(curl -s -T ${dir}/$logfilename "http://logfileupload.91yuntest.com/logfileupload.php")
echo -e $resultstr | tee -a ${dir}/$logfilename
}

if [[ $upfile == "y" ]]
then
updatefile
else
echo "测试结束,具体日志查看 91yuntest.log"
fi
#删除目录
rm -rf ${dir}/91yuntest

20 changes: 10 additions & 10 deletions test_code/allping.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ allping()

ipipallpingsum()
{
echo "===ping show===" >>${dir}/$logfilename
echo "===ping show==="
t=`cat allping.log`
t=`echo -e "$t" | grep -oE "<script>parent\.summary_ping\([^<]*\)<\/script>" | sed -r 's@<script>parent.summary_ping\(([^<]*)\)<\/script>@\1@g'`
t=`echo "$t" | grep -oE '"[^"]*":{"count":[^,]*,"total":"[^,]*","min_speed":"[^,]*","min_name":"[^,]*","max_speed":"[^,]*","max_name":"[^,]*","avg":"[^,]*"}' `
printf "%-10s\t%-24s\t%-10s%-24s\t%-10s%-10s\n" "线路" "最快节点" "延迟" "最慢节点" "延迟" "平均延迟"
echo -e "线路\t节点数目\t最快节点\t延迟\t最慢节点\t延迟\t平均延迟" >>${dir}/$logfilename
echo -e "线路\t节点数目\t最快节点\t延迟\t最慢节点\t延迟\t平均延迟"
while read line || [ -n "$line" ]
do

Expand All @@ -35,18 +35,18 @@ ipipallpingsum()
avg=`echo "$line" | grep -oE '"avg":"[^,]*"' | sed 's/"//g' | awk -F ":" '{print $2}'`

printf "%-10s\t%-24s\t%-10s%-24s\t%-10s%-10s\n" "$key" "$min_name" "$min_speed" "$max_name" "$max_speed" "$avg"
echo -e "$key\t$count\t$min_name\t$min_speed\t$max_name\t$max_speed\t$avg" >>${dir}/$logfilename
echo -e "$key\t$count\t$min_name\t$min_speed\t$max_name\t$max_speed\t$avg"
done < <(echo "$t")
echo "===ping show end===" >>${dir}/$logfilename
echo "" >>${dir}/$logfilename
echo "===ping show end==="
echo ""
}

ipipallpinglog()
{
t=`grep -oE '<script>parent\.call_ping\([^<]*\);<\/script>' ./allping.log | sed 's@"text":"[^"]*",@@g' | sed 's@"link_url":"[^"]*"@@g' | sed 's@"link_name":"[^"]*",@@g'`
t=`echo -e "$t" | sed -r 's@<script>parent\.call_ping\(([^<]*)\);<\/script>@\1@g'`
echo "===all ping start===" >>${dir}/$logfilename
echo "id\tping的地点\tIP\tIP所在地\t丢包率\tMIX\tMAX\t延迟\tTTL" >>${dir}/$logfilename
echo "===all ping start==="
echo "id\tping的地点\tIP\tIP所在地\t丢包率\tMIX\tMAX\t延迟\tTTL"
while read line || [ -n "$line" ]
do
id=`echo "$line" | grep -oE '"id":[0-9]+' | awk -F ":" '{print $2}'`
Expand All @@ -59,8 +59,8 @@ ipipallpinglog()
rtt_avg=`echo "$line" | grep -oE '"rtt_avg":"[^,]*"' | sed 's/"//g' | awk -F ":" '{print $2}'`
ttl=`echo "$line" | grep -oE '"ttl":"[^,]*"' | sed 's/"//g' | awk -F ":" '{print $2}'`

echo -e "$id\t$name\t$ip\t$ip_area\t$loss\t$rtt_min\t$rtt_max\t$rtt_avg\t$ttl" >>${dir}/$logfilename
echo -e "$id\t$name\t$ip\t$ip_area\t$loss\t$rtt_min\t$rtt_max\t$rtt_avg\t$ttl"
done < <(echo -e "$t")
echo "===all ping end===" >>${dir}/$logfilename
echo "" >>${dir}/$logfilename
echo "===all ping end==="
echo ""
}
6 changes: 3 additions & 3 deletions test_code/backtraceroute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ mtrinstall()
}
mtrback(){
type mtr >/dev/null 2>&1 || mtrinstall
echo "===测试 [$2] 的回程路由===" | tee -a ${dir}/$logfilename
mtr -r --tcp -w -b -c 10 $1 | tee -a ${dir}/$logfilename
echo "===测试 [$2] 的回程路由==="
mtr -r --tcp -w -b -c 10 $1
echo -e "\n\n"
echo -e "===回程 [$2] 路由测试结束===\n\n" >> ${dir}/$logfilename
echo -e "===回程 [$2] 路由测试结束===\n\n"

}

Expand Down
8 changes: 4 additions & 4 deletions test_code/bandwidth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bandwidth()
wget --no-check-certificate https://bintray.com/ookla/download/download_file?file_path=ookla-speedtest-1.0.0-${arch}-linux.tgz -O speedtest.tgz 1>/dev/null 2>&1
tar xfvz speedtest.tgz >/dev/null 2>&1
chmod +x speedtest
bd=`./speedtest --accept-license | awk -F '(' '{print $1}'`
bd=`./speedtest --accept-license --accept-gdpr | awk -F '(' '{print $1}'`


#显示在屏幕上
Expand All @@ -14,7 +14,7 @@ bandwidth()


#写入日志文件
echo "===开始测试带宽===">>${dir}/$logfilename
echo "$bd">>${dir}/$logfilename
echo -e "===带宽测试结束==\n\n">>${dir}/$logfilename
echo "===开始测试带宽==="
echo "$bd"
echo -e "===带宽测试结束==\n\n"
}
6 changes: 3 additions & 3 deletions test_code/benchtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ benchtest()

#Run unixbench
make > /dev/null 2>&1
echo "===开始测试bench===" >> ${dir}/${logfilename}
echo "===开始测试bench==="
./Run
benchfile=`ls results/ | grep -v '\.'`
cat results/${benchfile} >> ${dir}/${logfilename}
echo "===bench测试结束===" >> ${dir}/${logfilename}
cat results/${benchfile}
echo "===bench测试结束==="
cd ..
rm -rf UnixBench5.1.3.tgz UnixBench
}
2 changes: 1 addition & 1 deletion test_code/chinabw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cbw()
then
printf "%-18s%-18s%-20s%-12s\n" "$2" "$upload" "$download" "$latency"
#写入日志文件
echo "$2|$upload|$download|$latency">>${dir}/$logfilename
echo "$2|$upload|$download|$latency"
fi


Expand Down
16 changes: 8 additions & 8 deletions test_code/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ speed_test() {
ipaddress=$(ping -c1 -n `awk -F'/' '{print $3}' <<< $1` | awk -F'[()]' '{print $2;exit}')
nodeName=$2
if [ "${#nodeName}" -lt "8" ]; then
echo -e "$2\t\t\t\t$ipaddress\t\t$speedtest" | tee -a ${dir}/$logfilename
echo -e "$2\t\t\t\t$ipaddress\t\t$speedtest"
elif [ "${#nodeName}" -lt "13" ]; then
echo -e "$2\t\t\t$ipaddress\t\t$speedtest" | tee -a ${dir}/$logfilename
echo -e "$2\t\t\t$ipaddress\t\t$speedtest"
elif [ "${#nodeName}" -lt "24" ]; then
echo -e "$2\t\t$ipaddress\t\t$speedtest" | tee -a ${dir}/$logfilename
echo -e "$2\t\t$ipaddress\t\t$speedtest"
elif [ "${#nodeName}" -ge "24" ]; then
echo -e "$2\t$ipaddress\t\t$speedtest" | tee -a ${dir}/$logfilename
echo -e "$2\t$ipaddress\t\t$speedtest"
fi
}
download()
{
echo "===开始测试下载速度===">>${dir}/$logfilename
echo "===开始测试下载速度==="
next
echo "===star ipv4 download===">>${dir}/$logfilename
echo -e "Node Name\t\t\tIPv4 address\t\tDownload Speed" | tee -a ${dir}/$logfilename
echo "===star ipv4 download==="
echo -e "Node Name\t\t\tIPv4 address\t\tDownload Speed"
speed_test 'http://cachefly.cachefly.net/100mb.test' 'CacheFly'
speed_test 'http://speedtest.tokyo2.linode.com/100MB-tokyo2.bin' 'Linode, Tokyo, JP'
# speed_test 'http://speedtest.singapore.linode.com/100MB-singapore.bin' 'Linode, Singapore, SG'
Expand All @@ -30,5 +30,5 @@ download()
# speed_test 'http://speedtest.fra02.softlayer.com/downloads/test100.zip' 'Softlayer, Frankfurt, DE'
speed_test 'http://speedtest.sng01.softlayer.com/downloads/test100.zip' 'Softlayer, Singapore, SG'
speed_test 'http://speedtest.hkg02.softlayer.com/downloads/test100.zip' 'Softlayer, HongKong, CN'
echo -e "===end ipv4 download===\n\n">>${dir}/$logfilename
echo -e "===end ipv4 download===\n\n"
}
10 changes: 5 additions & 5 deletions test_code/gotoping.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
testping()
{
echo "{start testing $2 ping}" >> ${dir}/$logfilename
ping -c 5 $1 | tee -a ${dir}/$logfilename
echo "{start testing $2 ping}"
ping -c 5 $1
echo -e "\n\n"
echo "{end testing}" >> ${dir}/$logfilename
echo "{end testing}"
}

gotoping()
{
echo "===开始测试跳板ping===">>${dir}/$logfilename
echo "===开始测试跳板ping==="
next
testping speedtest.tokyo2.linode.com Linode日本
testping hnd-jp-ping.vultr.com Vultr日本
testping 192.157.214.6 Budgetvm洛杉矶
testping speedtest.kdatacenter.com kdatacenter韩国SK
testping 210.92.18.1 星光韩国KT
echo "===跳板ping测试结束===">>${dir}/$logfilename
echo "===跳板ping测试结束==="
}
10 changes: 5 additions & 5 deletions test_code/io.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ io()
echo "Average I/O speed : $ioavg MB/s"

#写入日志文件
echo "===开始测试IO性能===">>${dir}/$logfilename
echo "I/O speed(1st run) : $io1">>${dir}/$logfilename
echo "I/O speed(2nd run) : $io2">>${dir}/$logfilename
echo "I/O speed(3rd run) : $io3">>${dir}/$logfilename
echo "Average I/O: $ioavg MB/s">>${dir}/$logfilename
echo "===开始测试IO性能==="
echo "I/O speed(1st run) : $io1"
echo "I/O speed(2nd run) : $io2"
echo "I/O speed(3rd run) : $io3"
echo "Average I/O: $ioavg MB/s"
}
34 changes: 17 additions & 17 deletions test_code/systeminfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ systeminfo()
echo "OS : $opsy $arch $kern"

#写入日志文件
echo "===系统基本信息===">>${dir}/$logfilename
echo "CPU:$cname">>${dir}/$logfilename
echo "cores:$cores">>${dir}/$logfilename
echo "freq:$freq">>${dir}/$logfilename
echo "ram:$tram">>${dir}/$logfilename
echo "swap:$swap">>${dir}/$logfilename
echo "uptime:$up">>${dir}/$logfilename
echo "OS:$opsy">>${dir}/$logfilename
echo "Arch:$arch ($lbit Bit)">>${dir}/$logfilename
echo "Kernel:$kern">>${dir}/$logfilename
echo "ip:$IP">>${dir}/$logfilename
echo "ipaddr:$IPaddr">>${dir}/$logfilename
echo "host:$hostp">>${dir}/$logfilename
echo "uptime:$up">>${dir}/$logfilename
# echo "vm:$vm">>${dir}/$logfilename
echo "he:$he">>${dir}/$logfilename
echo -e "\n\n">>${dir}/$logfilename
echo "===系统基本信息==="
echo "CPU:$cname"
echo "cores:$cores"
echo "freq:$freq"
echo "ram:$tram"
echo "swap:$swap"
echo "uptime:$up"
echo "OS:$opsy"
echo "Arch:$arch ($lbit Bit)"
echo "Kernel:$kern"
echo "ip:$IP"
echo "ipaddr:$IPaddr"
echo "host:$hostp"
echo "uptime:$up"
# echo "vm:$vm"
echo "he:$he"
echo -e "\n\n"
}
8 changes: 4 additions & 4 deletions test_code/traceroute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ipiptraceroute()
t=`echo "$t" | sed -r "s/<script>parent.resp_once\((.*)\)<\/script>/\1/g"`

echo "===测试 [$2] 到这台服务器的路由==="
echo "===start test traceroute from [$2]===" >>${dir}/$logfilename
echo "===start test traceroute from [$2]==="
while read line || [ -n "$line" ]
do
num=`echo "$line" | grep -oE "^'[0-9]+'" | grep -oE "[0-9]+"`
Expand Down Expand Up @@ -68,11 +68,11 @@ ipiptraceroute()
fi

printf "%-5s\t%-20s\t%-60s\t%-10s\n" "$num" "$host" "$area" "$time"
echo "$num#$ip#$host#$area#$time" >>${dir}/$logfilename
echo "$num#$ip#$host#$area#$time"

done < <(echo "$t")
echo "=== [$2] traceroute test ended===" >>${dir}/$logfilename
echo "=== [$2] traceroute test ended==="
echo ""
echo "" >>${dir}/$logfilename
echo ""
}

Loading

0 comments on commit abd9616

Please sign in to comment.