Last active
October 9, 2019 22:29
-
-
Save nexus166/160229a9aca567ce1dd9c96b0bfddbe9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env bash | |
| set -eo pipefail | |
| TARGETs=(${@}) | |
| avg_lat() { basename $(ping -s 4096 -c 10 -q "${1}" | awk '/avg/ {print $4}'); } | |
| w8() { c=0; for p in ${@}; do (wait ${p} 2>/dev/null || c=$?) & done; wait; } | |
| work() { echo -e "$(avg_lat ${1})\\t${1}\\t$(curl -s ipinfo.io/${1} | jq -r '.loc,.country,.region' | tr '\n' '\t')"; } | |
| pids=() | |
| echo -e "RTT\\tADDR\\t\\tLOC\\t\\tCOUNTRY\\tREGION" | |
| for _ip in ${TARGETs[@]}; do | |
| pids+=($!); | |
| work "${_ip}" & | |
| done | sort -V & w8 ${pids[@]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment