Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gregtaylor99/428baa778da6ab42ead504164909aba0 to your computer and use it in GitHub Desktop.
Save gregtaylor99/428baa778da6ab42ead504164909aba0 to your computer and use it in GitHub Desktop.
monitor available docker free space in ECS
#!/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