Skip to content

Instantly share code, notes, and snippets.

@illustris illustris/corss.sh
Last active Dec 5, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.