Created
December 15, 2017 05:36
-
-
Save plutocrat/d2261c5fc110ce55d3dd8b7062d0479b to your computer and use it in GitHub Desktop.
Pull various useful info from AWS meta data interface
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 | |
OUTFILE=server-info.txt | |
NEWFILE=1 | |
# Clear existing if NEWFILE set to 1 | |
if [ "$NEWFILE" == "1" ]; then | |
echo "" > $OUTFILE | |
fi | |
# Log date | |
echo "== Run on $(date) ==" >> $OUTFILE | |
# Network info | |
for PARAM in local-hostname local-ipv4 public-hostname public-ipv4 ; | |
do | |
ANSWER=$(curl -s http://169.254.169.254/latest/meta-data/"$PARAM"/) | |
echo "$PARAM = $ANSWER" | tee -a $OUTFILE | |
done | |
echo "------------------------------" | tee -a $OUTFILE | |
# Useful AWS info | |
for PARAM in instance-id security-groups placement/availability-zone ; | |
do | |
ANSWER=$(curl -s http://169.254.169.254/latest/meta-data/"$PARAM"/) | |
echo "$PARAM = $ANSWER" | tee -a $OUTFILE | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment