Skip to content

Instantly share code, notes, and snippets.

@pahud
Last active March 23, 2018 01:36
Show Gist options
  • Save pahud/7e1c5f434af2e2a89792368c04a98e81 to your computer and use it in GitHub Desktop.
Save pahud/7e1c5f434af2e2a89792368c04a98e81 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