Tunnel VisualVM (JMX) over SSH
daniel Tue, 05/31/2011 - 4:18pm
You can tunnel VisualVM (JMX) over SSH with an SSH dynamic tunnel
(This tutorial will work perfectly with Linux, not sure about MacOS. Windows users will need some Putty skills.)
First, you will need to setup JMX for your application, this is outside the scope of this note, but you can find more info elsewhere on this site.
Now, on your local machine, you are going to create a dynamic (application) tunnel to the server:
ssh -D 61444 myhost.com
For more about -D see the OpenBSD / OpenSSH Man Pages
Again, on your local machine, start Java VisualVM using a SOCKS Proxy
(See Comment Below Regarding Alternate Method):
jvisualvm -J-Dnetbeans.system_socks_proxy=localhost:61444 -J-Djava.net.useSystemProxies=true
You should now be seeing Java VisualVM.
Now add the Remote Host: On the icon labeled "Remote", right-click and select "Add Remote Host". Enter the Ip Address of the host you are trying to connect to in the "Host Name" field. Click "OK"
Add the JMX connection: Right click on the new Host Icon, and click "Add JMX Connection". Simply append the port number for your application to the Connection Field. Then click "OK".
You should now be able to right-click on the new JMX connection icon and view info about your app.