Last active
October 10, 2020 18:27
-
-
Save skirsten/95611acf6d309371e720595deccc0a9c to your computer and use it in GitHub Desktop.
Pings all AWS regions and sorts by RTT.
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/bash | |
# Usage: `./aws-ping.sh` prints all regions sorted by lowest latency and `./aws-ping.sh 3` prints the top 3 regions. | |
declare -A zones=( | |
[us-east-2]="US East (Ohio)" | |
[us-east-1]="US East (N. Virginia)" | |
[us-west-1]="US West (N. California)" | |
[us-west-2]="US West (Oregon)" | |
[af-south-1]="Africa (Cape Town)" | |
[ap-east-1]="Asia Pacific (Hong Kong)" | |
[ap-south-1]="Asia Pacific (Mumbai)" | |
[ap-northeast-3]="Asia Pacific (Osaka-Local)" | |
[ap-northeast-2]="Asia Pacific (Seoul)" | |
[ap-southeast-1]="Asia Pacific (Singapore)" | |
[ap-southeast-2]="Asia Pacific (Sydney)" | |
[ap-northeast-1]="Asia Pacific (Tokyo)" | |
[ca-central-1]="Canada (Central)" | |
[eu-central-1]="Europe (Frankfurt)" | |
[eu-west-1]="Europe (Ireland)" | |
[eu-west-2]="Europe (London)" | |
[eu-south-1]="Europe (Milan)" | |
[eu-west-3]="Europe (Paris)" | |
[eu-north-1]="Europe (Stockholm)" | |
[me-south-1]="Middle East (Bahrain)" | |
[sa-east-1]="South America (São Paulo)" | |
) | |
file=`mktemp` | |
for zone in "${!zones[@]}"; do | |
name=${zones[$zone]} | |
rtt=`ping -qc1 dynamodb.$zone.amazonaws.com 2>&1 | awk -F'/' 'END{ print (/^rtt/? $5:"FAIL") }'` | |
echo "$rtt ms: $zone [$name]" >> $file | |
done | |
if [ -n "$1" ]; then | |
sort -n $file | head -$1 | |
else | |
sort -n $file | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment