Monitoring a remote JVM process
Monitoring a remote JVM process has never been easier. As part of the default JDK installation you have a utility called jconsole at your fingertips. jconsole provides a simple way to attach to a running JVM process either locally or remotely. There are basically two ways to attach to the process, either choosing to attach to the PID or through JMX. Personally, I find that attaching to a PID is the easiest either remotely or locally.
Attaching to a process remotely might seem difficult or impossible, but if you are able to use X11 window forwarding through SSH it is a nice option. Check your /etc/ssh/ssh_config and make sure that you see ForwardX11 is set to “yes”, sometimes it isĀ X11Forwarding, check your Linux distribution to be sure.
Host * # ForwardAgent no ForwardX11 yes
Once you have made this change, restart your ssh serviceĀ /etc/init.d/ssh restart or service ssh restart. Voila. Now ssh onto your remote server with the X option
ssh -X user@remote.server.com
So once you’ve SSH’d into your remote server startup jconsole, assuming it is in your PATH you should be able to just type it straight away. You should then immediately see that jconsole has started up through X11 as if it were running on your local machine. Just select the PID and you will be able to start monitoring memory, threads, garbage collection, etc.

jconsole
Generally when I am load testing an application (I use JMeter) on the JVM I will crack open jconsole to see if there are any blaring memory leaks or memory consumption problems.
Follow me on Twitter
My github repository
My LinkedIn Profile