Skip to content

Instantly share code, notes, and snippets.

@YukariChiba
Created October 27, 2022 01:44
Show Gist options
  • Select an option

  • Save YukariChiba/ff9707e1a7eca0f9ff4c0b358714b497 to your computer and use it in GitHub Desktop.

Select an option

Save YukariChiba/ff9707e1a7eca0f9ff4c0b358714b497 to your computer and use it in GitHub Desktop.
#!/bin/bash
NODES=(
"APR1.HK"
"LON1.UK"
"LAX1.US"
"LAS1.US"
"VUL1.SG"
"NYC1.US"
"TYO1.JP"
"LL1.NL"
"FRA1.DE"
"SOL1.KR"
"FMT2.US"
)
declare -A res
for node in ${NODES[@]}; do
echo "Testing $node"
nodeping=`ping -c 4 $node.dn42.strexp.net | tail -1 | awk -F '/' '{print $5}' 2>/dev/null`
if [ -z "$nodeping" ]; then
echo "$node unreachable"
else
echo "$node $nodeping"
res[`echo $node | sed "s:\.:_:"`]=$nodeping
fi
done
printf "\n\nResult:\n"
printf "Node\t\tLatency\n"
for k in "${!res[@]}"
do
printf "%s\t\t%s\n" $k ${res["$k"]}ms
done | sort -rn -k2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment