Created
October 26, 2017 16:03
-
-
Save trevorc/601a6ffa6164f547899ab3da3625329f to your computer and use it in GitHub Desktop.
Find closest server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
count=$1 | |
server=$2 | |
latency=$(ping -nqc${count} ${server} | | |
sed -nE 's,^round[^=]*=[^/]*/([[:digit:]]+\.[[:digit:]]+).*,\1,p') | |
echo "${latency} ${server}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
PARALLEL=${PARALLEL:-64} | |
COUNT=${COUNT:-6} | |
xargs \ | |
-P $PARALLEL \ | |
-n 1 \ | |
sh ping_server.sh $COUNT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment