Last active
March 23, 2018 01:36
-
-
Save pahud/7e1c5f434af2e2a89792368c04a98e81 to your computer and use it in GitHub Desktop.
monitor available docker free space in ECS
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 | |
instanceid=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) | |
region=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | awk -F\" '/region/ {print $4}') | |
ip=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) | |
free_space=$(docker info |grep "Data Space Available" |grep G |awk -F "." {'print $1'} |awk {'print $NF'}) | |
metric_name='DockerFreeSpace' | |
aws --region=${region} cloudwatch put-metric-data --metric-name DockerFreeSpace --namespace ECS \ | |
--value ${free_space} --dimensions IP=${ip} | |
aws --region=${region} cloudwatch put-metric-data --metric-name DockerFreeSpace --namespace ECS \ | |
--value ${free_space} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment