Last active
February 9, 2017 17:23
-
-
Save elocnatsirt/061e6ea63e37523de838f294fb4881eb to your computer and use it in GitHub Desktop.
Retrieves information about an AWS instance and outputs it via stdout. Written to use as a Sensu check to get basic information about a client.
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 | |
# Written By: https://github.com/elocnatsirt | |
# This script will curl the instance metadata and output useful values | |
# If the system isn't in AWS it will succeed with a relevant message | |
instance_id=`curl --silent http://169.254.169.254/latest/meta-data/instance-id` | |
instance_type=`curl --silent http://169.254.169.254/latest/meta-data/instance-type` | |
location=`curl --silent http://169.254.169.254/latest/meta-data/placement/availability-zone` | |
region=`curl --silent http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/.$//'` | |
if [ "$instance_id" == "" ]; then | |
echo "This is not an AWS instance" | |
exit 0 | |
fi | |
echo "Location: ${location}" | |
echo "Instance ID: ${instance_id}" | |
echo "Instance Type: ${instance_type}" | |
echo "Cloudwatch Link: https://console.aws.amazon.com/cloudwatch/home?region=${region}#metrics:metricFilter=Search%253D${instance_id}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment