sensu-plugins / sensu-plugins-java

Sensu Java Plugins
http://sensu-plugins.io
MIT License
5 stars 25 forks source link

JVM Used Heap Calculation #11

Closed rahulsh1 closed 7 years ago

rahulsh1 commented 7 years ago

The current total heap calculation is TotalHeap=jstat -gccapacity $PID | tail -n 1 | awk '{ print ($4 + $5 + $6 + $10) / 1024 }' This includes: S0C, S1C, EC & OC (survivor, eden and Old space)

MC is not part of calculation above which seems to be correct. However current heap calculation includes Metaspace utilization(MU) UsedHeap=jstat -gc $PID | tail -n 1 | awk '{ print ($3 + $4 + $6 + $8 + $10) / 1024 }' This includes: S0U, S1U, EU, OU and MU

Since MU is outside of JVM Heap, IMO, that shouldn't be part of the calculation. The calculation should be UsedHeap=$(sudo ${JAVA_BIN}jstat -gc $PID | tail -n 1 | awk '{ print ($3 + $4 + $6 + $8) / 1024 }')

Kidinicol commented 7 years ago

I have noticed the same issue when using applications with java 8 installed so I followed your instructions and changed the following plugins check-java-heap-pcnt.sh (removed the $10 entry on the usedheap) java-heap-graphite.sh (removed the $10 entry on the used heap and removed the PermGen ) jstat-metrics.py (removed from -gc the PC PU terms and added the MC,MU,CCSC,CCSU , also removed from -gccapacity PGCMN, PGCMX, PGC, PC and added MCMN, MCMX, MC,CCSMN, CCSMX, CCSC )

majormoses commented 7 years ago

@rahulsh1 I have looked at this very briefly and am no java expert but from what I can tell is that this is to do with the fact that in java 7 and 8 they have different columns reported on. As java 7 is EOL I am ok with this breaking change though and after the requested changes are made on the PR I can release this as a new major version.

majormoses commented 7 years ago

released: https://rubygems.org/gems/sensu-plugins-java/versions/0.0.6

majormoses commented 7 years ago

please confirm this release solves your issues.

majormoses commented 7 years ago

closing as a fix was merged and lack of response confirming their issue has been resolved.