Last active
August 29, 2015 14:27
-
-
Save Luit/2f7235db183813eee0b1 to your computer and use it in GitHub Desktop.
check_docker_memory function
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
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 | |
} |
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
Inspired by https://www.aerofs.com/blog/a-little-golang-way/
Even though
sort -n
may be wrong now, you can stillcheck_docker_memory | sort -h