1. Login to the ec2 instance.
2. curl http://169.254.169.254/latest/meta-data/ [ This will show you all the system's meta-data that can be extracted using the command line:
example:
curl http://169.254.169.254/latest/meta-data/
ami-id
ami-launch-index
ami-manifest-path
block-device-mapping/
hostname
instance-action
instance-id
instance-type
kernel-id
local-hostname
local-ipv4
mac
metrics/
network/
placement/
profile
public-hostname
public-ipv4
public-keys/
reservation-id
Further few of the above meta-data have few more sub values as:
block-device-mapping/ [ Over here you will get ec2 instance's disk information. ]
ami
ephemeral0
root
swap
metrics/
vhostmd [ you will get some output like: <?xml version="1.0" encoding="UTF-8"?> ]
network/
interfaces/
macs/ [ network/interfaces/macs -> you will get the mac info [ same as user-data/mac ]
macs/ [ network/interfaces/macs -> you will get the mac info [ same as user-data/mac ]
placement/
availability-zone [ you will get the host's zone information example: us-east-1 ]
public-keys/
0=key_info
Further information about each of these meta data can be found at the following location:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html
http://docs.aws.amazon.com/AWSEC2/2007-03-01/DeveloperGuide/AESDG-chapter-instancedata.html
This use a REST (RESTful) API or a web api to fetch system informations.
Following is a simple curl command to get most of the system details in a single line:
for i in `curl http://169.254.169.254/latest/meta-data/`; do echo ${i}; curl http://169.254.169.254/latest/meta-data/${i}/; echo -e '\n' ; done
I believe few of the following informations you might need handy: [ that you can create a small bash script and put that in your command path [ e.g. /bin/ as hostinfo.sh ]
echo "ami-id: "; curl http://169.254.169.254/latest/meta-data/ami-id/; echo -e "\n"
echo "hostname: "; curl http://169.254.169.254/latest/meta-data/hostname/; echo -e "\n"
echo "instance-type: "; curl http://169.254.169.254/latest/meta-data/instance-type/; echo -e "\n"
echo "local-hostname: "; curl http://169.254.169.254/latest/meta-data/local-hostname/; echo -e "\n"
echo "local-ipv4: "; curl http://169.254.169.254/latest/meta-data/local-ipv4/; echo -e "\n"
echo "mac: "; curl http://169.254.169.254/latest/meta-data/mac/; echo -e "\n"
echo "zone: "; curl http://169.254.169.254/latest/meta-data/placement/availability-zone/; echo -e "\n"
echo "public-hostname: "; curl http://169.254.169.254/latest/meta-data/public-hostname/; echo -e "\n"
echo "public-ipv4: "; curl http://169.254.169.254/latest/meta-data/public-ipv4/; echo -e "\n"
echo "public-keys: "; curl http://169.254.169.254/latest/meta-data/public-keys/; echo -e "\n"
echo "security-group: "; curl http://169.254.169.254/latest/meta-data/security-groups/; echo -e "\n"
vi publicip
curl http://169.254.169.254/latest/meta-data/public-ipv4/; echo -e "\n"Make sure, you grant this scripts with executable permission.
No comments:
Post a Comment