Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sashareds/12f3dbb3b6aaaeaeb95bfdcfc541dbeb to your computer and use it in GitHub Desktop.
Save sashareds/12f3dbb3b6aaaeaeb95bfdcfc541dbeb to your computer and use it in GitHub Desktop.
Ping all AWS EC2 IPs from http://ec2-reachability.amazonaws.com/

This is a fork from of Ping all AWS EC2 IPs script. It didnt work for me so I had to figure it out on my own. I only copied IPs from http://ec2-reachability.amazonaws.com for Europe(Ireland, London, Paris, Frankfurt & Stockholm). It's easy to make your own csv files with your own regions.

To run the script

  1. chmod u-x scriptname.sh
  2. then just run # bash scriptname.sh OR simply # ./scriptname.sh the result will be printed in your shell.
  3. If you'd like to output its results into a file, just run this # ./scriptname.sh > results.txt

That's it!

Things to do:

  1. tidy up the output. For some weird reason script fails to process the first ping sometimes and prints out an error. Also, it prints the variables as the first line of the output, no idea why for now.
  2. figure out how to nicely columnise the output. For now column doesnt pick up the output fully.
  3. Add an option to ping only particular country.
  4. make this script available to run with wget/curl
Country Region IP
Ireland eu-west-1 18.202.0.0
Ireland eu-west-1 34.240.0.253
Ireland eu-west-1 34.248.60.213
Ireland eu-west-1 46.51.178.50
Ireland eu-west-1 46.137.120.1
Ireland eu-west-1 46.137.191.254
Ireland eu-west-1 52.16.0.2
Ireland eu-west-1 52.19.0.2
Ireland eu-west-1 52.30.63.252
Ireland eu-west-1 52.48.63.252
Ireland eu-west-1 52.215.255.254
Ireland eu-west-1 54.72.255.252
Ireland eu-west-1 54.73.0.1
Ireland eu-west-1 54.74.0.1
Ireland eu-west-1 54.76.0.3
Ireland eu-west-1 54.78.0.3
Ireland eu-west-1 54.154.63.252
Ireland eu-west-1 54.155.0.1
Ireland eu-west-1 54.170.248.3
Ireland eu-west-1 54.171.63.252
Ireland eu-west-1 54.194.255.254
Ireland eu-west-1 54.216.0.1
Ireland eu-west-1 54.220.0.0
Ireland eu-west-1 54.228.250.251
Ireland eu-west-1 54.229.0.1
Ireland eu-west-1 54.240.0.0
Ireland eu-west-1 54.240.56.254
Ireland eu-west-1 54.246.127.255
Ireland eu-west-1 54.247.127.254
Ireland eu-west-1 63.32.0.0
Ireland eu-west-1 79.125.120.9
Ireland eu-west-1 99.80.0.0
Ireland eu-west-1 108.128.0.0
Ireland eu-west-1 176.34.127.254
Ireland eu-west-1 176.34.255.255
Ireland eu-west-1 185.48.120.66
London eu-west-2 3.8.0.0
London eu-west-2 18.130.0.0
London eu-west-2 35.176.0.252
London eu-west-2 35.178.0.253
London eu-west-2 52.56.34.0
Paris eu-west-3 35.180.0.253
Paris eu-west-3 35.181.0.0
Paris eu-west-3 52.47.32.127
Frankfurt eu-central-1 3.120.0.0
Frankfurt eu-central-1 3.124.0.0
Frankfurt eu-central-1 18.184.0.0
Frankfurt eu-central-1 18.194.0.252
Frankfurt eu-central-1 18.196.0.253
Frankfurt eu-central-1 35.156.63.252
Frankfurt eu-central-1 52.28.63.252
Frankfurt eu-central-1 52.29.63.252
Frankfurt eu-central-1 52.57.255.254
Frankfurt eu-central-1 52.58.63.252
Frankfurt eu-central-1 54.93.32.2
Frankfurt eu-central-1 54.93.162.162
Stockholm eu-north-1 13.53.128.254
Automatic ping of all AWS EC2 IPs from http://ec2-reachability.amazonaws.com/
#!/bin/bash
#debugging
#exec 7> debug_output.txt
#BASH_XTRACEFD=7
#PS4='$LINENO: '
#set -x
#
IFS=","
#printing tabke header
echo "COUNTRY, REGION, IP, RTT"
cat awsiplist.csv | while read Country Region IP
do
#extractung avarage Rouns Trip Time
rtt=`ping -c 5 $IP | tail -1| gawk '{print $4}' | cut -d '/' -f 2`
#printing results into the table (needs some work tho)
printf "$Country, $Region, $IP, $rtt ms (avg) \n" | column -s ',' -t
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment