I’ve written a handful of times on observing and tuning the JVM using tools such as Jstat. I recently upgraded our servers to Java 8 and found that my Jstat script could no longer find the process no matter what I tried.
It turns out there is a bug from JDK 1.7 u75 onwards that is present at least through JDK 1.8 u60 which prevents Jstat, when run as root, from introspecting JREs running as other users.
To solve, simply run jstat as the user who owns the JRE process. You can pass the username to sudo when running jstat like:
sudo -u nobody jstat -gcutil -t <pid> 1s 30
And you’ll be treated to your output again. In my case, I have two server instances running so I like to see their output side by side at the console. Here’s my script for doing that using /usr/bin/paste and some console redirection trickery:
The username can be figured out from the process but this was a quick fix for the above bug.
Comments are closed.