Skip to content

Instantly share code, notes, and snippets.

@Luit
Last active August 29, 2015 14:27
Show Gist options
  • Save Luit/2f7235db183813eee0b1 to your computer and use it in GitHub Desktop.
Save Luit/2f7235db183813eee0b1 to your computer and use it in GitHub Desktop.
check_docker_memory function
function check_docker_memory {
for id in $(docker ps -q --no-trunc); do
name=$(docker inspect -f "{{.Name}}" $id)
echo $(numfmt --to=iec --suffix=B $(cat /sys/fs/cgroup/memory/system.slice/docker-$id.scope/memory.usage_in_bytes)) ${name#/}
done
}
@Luit
Copy link
Author

Luit commented Aug 19, 2015

Inspired by https://www.aerofs.com/blog/a-little-golang-way/

Even though sort -n may be wrong now, you can still check_docker_memory | sort -h

@Luit
Copy link
Author

Luit commented Aug 19, 2015

One major thing that changed from the AeroFS version: I run docker on an OS with systemd, so the cgroup structure is slightly different (it's in system.slice for me)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment