JVisualVM is a great tool for monitoring JVM regarding memory issues, threads and GC … etc. There are two modes of communication between VisualVM and the JVM either over JMX or jstatd.
In this post I will only go through over JMX.
What I m trying to do
I will explain how to monitor a remote application through JMX by establishing an SSH tunnel.
- JAVA Application running on ubuntu machine 16.04
- JVisualVM comes with the the JVM, so you don’t have to install anything.so make sure that your local machine has visualvm otherwise download it.
- in case you want the latest version you can grab it from this link Download VisualVM
- Prepare JAVA application
- Establish ssh tunnel to the remote machine
- Run and Configure JVisualVM
1. JAVA application
- The only disadvantage about JMX is you need to start the JVM with some properties.
- So make sure you have the following arguments added to your jvm then restart your application.
Note : it’s important to set both ports jmx and rmi port
For more info regarding jmx connection, see Remote JMX Connections.
2. SSH TUNNEL
- Now it’s time to establish an ssh connection.
- Change the pem file, username and your remote ip address.
- Open VisualVM application
- On the left pannel click right on local then add new jmx connection.
- For the connection config put localhost:9010, then click OK.
- Now you are all set, just open the connection and start monitoring your application.