Created
January 2, 2019 04:33
-
-
Save jstangroome/223e76dea15ac3b5750892d44542f44c to your computer and use it in GitHub Desktop.
Create a CSV of each cgroup
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
#!/bin/bash | |
printf '%s,%s,%s,%s,%s,%s,%s,%s\n' \ | |
'dir' 'usage_in_bytes' \ | |
'cache' 'total_cache' \ | |
'rss' 'total_rss' \ | |
'rss_huge' 'total_rss_huge' | |
cd /sys/fs/cgroup/memory/ | |
while read -r usage_file | |
do | |
dir=$(dirname "${usage_file}") | |
usage_in_bytes=$(cat "${usage_file}") | |
unset data | |
declare -A data | |
while read -r field value | |
do | |
data["${field}"]="${value}" | |
done < <(grep 'cache\|rss' "${dir}/memory.stat") | |
printf '%s,%s,%s,%s,%s,%s,%s,%s\n' \ | |
"${dir}" "${usage_in_bytes}" \ | |
"${data[cache]}" "${data[total_cache]}" \ | |
"${data[rss]}" "${data[total_rss]}" \ | |
"${data[rss_huge]}" "${data[total_rss_huge]}" | |
done < <(find . -name memory.usage_in_bytes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment