Skip to content

Instantly share code, notes, and snippets.

@illustris
Last active December 5, 2019 06:30
Show Gist options
  • Save illustris/a86b8d6f555d12d99d019e8d860db0bb to your computer and use it in GitHub Desktop.
Save illustris/a86b8d6f555d12d99d019e8d860db0bb to your computer and use it in GitHub Desktop.
get memory utilization of corosync
#!/bin/bash
print_usage() {
echo "$0 - Get memory utilization of corosync"
echo ""
echo "$0 [options]"
echo "Options:"
echo "-h, --help show help"
echo "-b, --byte print rss in bytes (could get printed in scientific notation)"
echo "-k, --kbyte print rss in bytes (could get printed in scientific notation)"
echo ""
echo "Specifying no flags prints the rss value in human readable format"
}
kbytes=$(grep VmRSS /proc/$(pidof corosync)/status | grep kB | awk '{print $2}')
if [ $# -eq 0 ]
then
echo $kbytes | awk '{ split( "KB MB GB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } print int($1), v[s] }'
else
case "$1" in
-h|--help)
print_usage
;;
-b|byte)
echo $kbytes | awk '{print $1*1024}'
;;
-k|kbyte)
echo $kbytes
;;
*)
echo "Unknown option $1"
print_usage
;;
esac
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment