Skip to content

Instantly share code, notes, and snippets.

@plutocrat
Created December 15, 2017 05:36
Show Gist options
  • Save plutocrat/d2261c5fc110ce55d3dd8b7062d0479b to your computer and use it in GitHub Desktop.
Save plutocrat/d2261c5fc110ce55d3dd8b7062d0479b to your computer and use it in GitHub Desktop.
Pull various useful info from AWS meta data interface
#!/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