Tuesday, November 24, 2015

Connecting to remote Tomcat JMX instance using jConsole

Tried with Java 8

1. Add this to your java startup script on tomcat remote-host:

-Dcom.sun.management.jmxremote.port=1616
-Dcom.sun.management.jmxremote.rmi.port=1618
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

2. Execute this on your computer.

  • Windows users:
    putty.exe -ssh user@remote-host -L 1616:remote-host:1616 -L 1618:remote-host:1618
  • Linux and Mac Users:
    ssh user@remote-host -L 1616:remote-host:1616 -L 1618:remote-host:1618
This enable jconsole to connect to a remote-host via few ssh tunnels.

3. Open jconsole on your computer

jconsole localhost:1616

4. Have fun!

P.S.: during step 2, using ssh and -L you specify that the ports 1616 and 1818 on the local (client) host is to be forwarded to the remote side.