Closed rahulsh1 closed 7 years ago
If multiple processes have the same "jps" name, this causes command (jstat) to hang. $ check-java-heap-pcnt.rb -n jar -w 60 -c 80 <-- does not return
$ check-java-heap-pcnt.rb -n jar -w 60 -c 80
I have multiple java processes which runs using a jar name. jps shows both as jar.
jps
$ jps 29475 jar 2519 Jps 18875 jar $ PID=$(sudo jps | grep $NAME | awk '{ print $1}') # echo $PID 29475 18875 $ sudo jstat -gccapacity $PID | tail -n 1 | awk '{ print ($4 + $5 + $6 + $10) / 1024 }' <-- Does not return
However with the full package name listing, this can be easily fixed
$ jps -l 29475 myapp-1.0-SNAPSHOT.jar 2777 sun.tools.jps.Jps 18875 slave.jar
Adding -l to PID=$(sudo jps -l | grep $NAME | awk '{ print $1}') fixes this issue. I can then run
PID=$(sudo jps -l | grep $NAME | awk '{ print $1}')
$ check-java-heap-pcnt.rb -n myapp MEM OK - jvm heap usage: 6% | 73.1454 MB out of 1159 MB
closed per: https://github.com/sensu-plugins/sensu-plugins-java/issues/17
If multiple processes have the same "jps" name, this causes command (jstat) to hang.
$ check-java-heap-pcnt.rb -n jar -w 60 -c 80
<-- does not returnI have multiple java processes which runs using a jar name.
jps
shows both as jar.However with the full package name listing, this can be easily fixed
Adding -l to
PID=$(sudo jps -l | grep $NAME | awk '{ print $1}')
fixes this issue. I can then run