Skip to content

Instantly share code, notes, and snippets.

@trevorc
Created October 26, 2017 16:03
Show Gist options
  • Save trevorc/601a6ffa6164f547899ab3da3625329f to your computer and use it in GitHub Desktop.
Save trevorc/601a6ffa6164f547899ab3da3625329f to your computer and use it in GitHub Desktop.
Find closest server
#!/bin/sh
set -eu
count=$1
server=$2
latency=$(ping -nqc${count} ${server} |
sed -nE 's,^round[^=]*=[^/]*/([[:digit:]]+\.[[:digit:]]+).*,\1,p')
echo "${latency} ${server}"
#!/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