Last active
December 5, 2019 06:30
-
-
Save illustris/a86b8d6f555d12d99d019e8d860db0bb to your computer and use it in GitHub Desktop.
get memory utilization of corosync
This file contains hidden or 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 | |
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