Created
November 17, 2016 03:54
-
-
Save andy012/2e8b92ac890731a502cbccfd8e6a9c59 to your computer and use it in GitHub Desktop.
get jvm heap usage with shell
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 | |
pidVal=$( ps -ef | grep "/data/www/tomcat-unifymonitor/conf/logging.properties -" | grep -v grep | awk -F' ' '{print $2}' | tr "\n" "," | cut -d ',' -f1 ) | |
capacityLine=$(/usr/java/jdk1.7.0_65/bin/jstat -gccapacity ${pidVal} | tail -n 1 ) | |
percentageLine=$(/usr/java/jdk1.7.0_65/bin/jstat -gcutil ${pidVal} | tail -n 1) | |
memValReal=`gawk -v v1="$capacityLine" -v v2="$percentageLine" 'BEGIN{ | |
split(v1,cArray," "); | |
split(v2,pArray," "); | |
sum=0.0; | |
# S0C Current Usage = S0C*S0/100.0 | |
sum=sum + (cArray[4]*pArray[1]/100.0); | |
# S1C Current Usage = S1C*S1/100.0 | |
sum=sum + (cArray[5]*pArray[2]/100.0); | |
# Eden Current Usage = EC*E/100.0 | |
sum=sum + (cArray[6]*pArray[3]/100.0); | |
# Old Current Usage = OC*O/100.0 | |
sum=sum + (cArray[9]*pArray[4]/100.0); | |
sum=sum/1000000; | |
printf "%.2f\n",sum; | |
}'` | |
echo $memValReal | |
standardVal=3.0 | |
if [ $(echo "$memValReal > $standardVal" | bc) -eq 1 ];then | |
echo $memValReal | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment