Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
find fast server for mac
#/bin/bash
#By LordSimon
#Modify xi4oh4o
#ping -c 1 ssh.sshcenter.info
for i in $(seq 21) #will 21 modify you server number count
do
echo "s$i.usassh.com" >> server.list #modify s$i.usassh.com to you server hostname
done
export Local_Result=""
export fastest="999999999"
export fastest_server="NO_SERVER!"
for server in `cat ./server.list`
do
echo "Ping: $server"
Local_Result=`ping -c 1 -W 1 $server|grep 'round-trip min/avg/max/stddev ='`
echo $Local_Result
#get avg value
current_avg=`echo "$Local_Result"|awk -F/ '{print $5}'`
if [ "$current_avg" = "" ];then current_avg=$fastest;fi
if [ `echo "$current_avg<$fastest"|bc` = "1" ]
then
fastest="$current_avg"
fastest_server="$server"
fi
echo "===================="
echo "current fastest:$fastest_server [$fastest]"
echo "===================="
done
echo "Fastest Server: $fastest_server"
echo "avg:$fastest"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment