Skip to content

Instantly share code, notes, and snippets.

@kosfar
Last active October 7, 2017 18:15
Show Gist options
  • Save kosfar/7b8cdd43be95ebf77415d0bf13e0d40c to your computer and use it in GitHub Desktop.
Save kosfar/7b8cdd43be95ebf77415d0bf13e0d40c to your computer and use it in GitHub Desktop.
#!/bin/sh
for i in $(find /cgroup/memory/docker/* -type d); do
CONTAINER_ID=$(echo $i | awk -F'/' '{print $5}')
CONTAINER_NAME=$(docker ps --no-trunc | grep $CONTAINER_ID | awk '{print $2}')
MEM_LIMIT=$(($(cat $i/memory.limit_in_bytes)/1024/1024))
MEM_USED=$(($(cat $i/memory.usage_in_bytes)/1024/1024))
printf "%30s\t%5sM\t%5sM\t%s\n" $CONTAINER_NAME $MEM_LIMIT $MEM_USED $CONTAINER_ID
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment