Skip to content

Instantly share code, notes, and snippets.

@briansorahan
Last active August 29, 2015 14:03
Show Gist options
  • Save briansorahan/63a62be1f14f1775fd5e to your computer and use it in GitHub Desktop.
Save briansorahan/63a62be1f14f1775fd5e to your computer and use it in GitHub Desktop.
peek at the cgroup stats in sysfs for a docker container
#!/bin/bash
#
# Get docker container sysfs info
#
# Usage
# ./container-stats.bash <docker container id>
#
# Docker container id's can be found using
# docker ps -notrunc
#
function main {
local container_id="$1"; shift
local cgroup=/sys/fs/cgroup
for resource in cpu memory; do
local d=$cgroup/$resource/docker/$container_id
for f in $(find $d -name "*$resource*"); do
basename $f
cat $f | sed -r 's/^/\t/'
done
done
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment