Skip to content

Instantly share code, notes, and snippets.

@sunfuze
Created January 21, 2022 02:47
Show Gist options
  • Save sunfuze/71b521224f19fa797e81e281c29ddcfc to your computer and use it in GitHub Desktop.
Save sunfuze/71b521224f19fa797e81e281c29ddcfc to your computer and use it in GitHub Desktop.
show human readable cgroup memory stat
cat /sys/fs/cgroup/memory/memory.stat | awk 'BEGIN{suffixes_len=split("B KB MB GB",suffixes)} {n_suffix=1; while($2 > 1000 &&
n_suffix < suffixes_len) {$2 /= 1024; n_suffix++;}; printf "%20s %7.2f %2s\n",$1,$2,suffixes[n_suffix]}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment