Created
January 2, 2019 04:33
-
-
Save jstangroome/7ba4cf7f0a8492d4b5713aa8639e32dd to your computer and use it in GitHub Desktop.
Create a CSV of each cgroup's memory.usage_in_bytes and some related memory.stat values.
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