Running VisualVM over SSH-Tunnel using PuttyOccasionally, I have to monitor a running process at a client's end through VisualVM. Enabling JMX, which is used by VisualVM, requires an additional TCP/IP port through the firewall. Most of the time it is an act of congress to get the network folks to open necessary TCP/IP ports allowing to monitor through JMX. Therefore, an alternate mechanism is required.
In this blog I will demonstrate how to monitor a Java server process using VisualVM, provided you have SSH access through Putty. I am assuming the following is true:
Making everything work is a 3-step process:
Configuring the Java processBefore you can use JMX, you will have to start the Java process using the following additional command lines
java -server -Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.local.only=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.rmi.port=9495 \ -Dcom.sun.management.jmxremote.port=9494 \ -Dcom.sun.management.jmxremote.ssl=false \ your.java.ClassNameThe above command line will enable JMX on port 9494.
Creating an SSH tunnel in puttyThe following steps demonstrate configuration changes in Putty