Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89252af50b | ||
|
|
8fb833d3c4 |
@@ -62,11 +62,14 @@ case "${1,,}" in
|
||||
;;
|
||||
esac;
|
||||
|
||||
# collect info via: curl http://instance-data/latest/meta-data/
|
||||
instance_id=$(curl -s http://instance-data/latest/meta-data/instance-id)
|
||||
account_id=$(curl -s http://instance-data/latest/meta-data/identity-credentials/ec2/info/ | jq -r .AccountId)
|
||||
region=$(curl -s http://instance-data/latest/meta-data/placement/region)
|
||||
|
||||
# collect info via: curl http://169.254.169.254/latest/meta-data/
|
||||
instance_data=$(
|
||||
TOKEN=`curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` &&
|
||||
curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/dynamic/instance-identity/document
|
||||
)
|
||||
instance_id=$(echo "${instance_data}" | jq .instanceId)
|
||||
account_id=$(echo "${instance_data}" | jq .accountId)
|
||||
region=$(echo "${instance_data}" | jq .region)
|
||||
|
||||
if [ "${OUTPUT_TARGET}" = "text" ]; then
|
||||
LOG="${LOG}/check_ssh_user."$(date +"%F_%H%m%S")".log";
|
||||
@@ -82,9 +85,9 @@ if [ "${OUTPUT_TARGET}" = "text" ]; then
|
||||
echo "Max age no login : ${max_age_create} days";
|
||||
elif [ "${OUTPUT_TARGET}" = "json" ]; then
|
||||
echo '"Info": {'
|
||||
echo '"AccountId": "'${account_id}'",';
|
||||
echo '"Region": "'${region}'",';
|
||||
echo '"InstanceId": "'${instance_id}'",';
|
||||
echo '"AccountId": '${account_id}',';
|
||||
echo '"Region": '${region}',';
|
||||
echo '"InstanceId": '${instance_id}',';
|
||||
echo '"Hostname": "'$(hostname)'",';
|
||||
echo '"Date": "'$(date +"%F %T")'",';
|
||||
echo '"MaxAgeLogin": '${max_age_login}',';
|
||||
|
||||
Reference in New Issue
Block a user