Sometimes it can be useful to monitor performance of Java Virtual Machine (VM) on remote host. To do so, a very nice tool – VisualVM – can be used. It can be run on local host and get information from jstatd running on a remote host. In addition, VisualVM comes with a number of useful plugins. This blog describes how to run VisualVM with VisualGC, which is Visual Garbage Collection Monitoring Tool to monitor Tomcat on remote machine. However, the solution can be also applied to other applications running on JavaVM.

Remote machine

Run Tomcat

Add the following options to CATALINA_OPTS variable to enable JMX support in Apache Tomcat.


in my case:


You can find more information about Monitoring and Managing Tomcat here: Monitoring and Managing Tomcat

Run Tomcat:

We want to monitor Tomcat instance running on remote machine. To check whether it is running use:

ps aux | grep tomcat

The above command run on my remote machine returns the following:

tomcat6  28743  181  3.4 5136644 210932 ?      Sl   13:15   0:20 /opt/java-1.6.0_22/bin/java -Djava.util.logging.config.file=/var/lib/tomcat6/conf/ -Djava.awt.headless=true -Xms512m -Xmx3048m -XX:+UseConcMarkSweepGC -XX:MaxPermSize=512m -XX:-DisableExplicitGC -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.rmi.server.hostname= -Djava.endorsed.dirs=/usr/share/tomcat6/endorsed -classpath /usr/share/tomcat6/bin/bootstrap.jar -Dcatalina.base=/var/lib/tomcat6 -Dcatalina.home=/usr/share/tomcat6 org.apache.catalina.startup.Bootstrap start

Notice that pid is ’28743′.

To get JavaVM process status you can run jps command, which is Java Virtual Machine Process Status Tool. jps is located is your Java JDK HOME/bin directory. Description of jps command can be found here. Note that jps returns only Java processes run by the user, who runs jps. To get list of all Java processes run sudo jps. See examples below.

Outcome of jps run on my remote machine:

28144 Jps

Outcome of sudo jps run on my remote machine:

28743 Bootstrap
1673 CPService
28159 Jps
28897 Jstatd

Notice that lvmid for Tomcat (in this case – Bootstrap) is ’28743′ which is the same as pid.




to check the host name, e.g., agile003.

Make sure that in /etc/hosts file this hostname has IP by which it is visible to the machine that will be running VisualVM (local machine), e.g., agile003.

Run jstat Deamon

jstatd, which is jstat Daemon can be found in Java JDK HOME/bin. As described in documentation to jstatd, which can be found here: , create a file called jstatd.policy in any directory you choose, e.g., /home/joanna. The file should contain the following text:

grant codebase "file:${java.home}/../lib/tools.jar" {

Run jstatd using the following command. Make sure you run it with root permissions.

sudo jstatd

You can add the following flag to log the calls and see what is going on:


Local machine

Check access to jstatd


jps <hostname>

in my case

jps agile003

You should see the same output as for sudo jps running on remote machine.

1673 CPService
28743 Bootstrap
28897 Jstatd

Run VisualVM





jvisualvm can be located in your Java JDK HOME/bin directory also it can be downloaded from here: JVM download

Go to

Tools -> Plugins

and install the plugins you require including VisualGC plugin. My selection is presented in the screen shot below.

Restart VisualVM.

Add remote host – one that jstatd is running on.

File -> AddRemoteHost...

give IP of the host, e.g., The same IP should be set for the host name in /etc/hosts on remote server.

Now you should be able to access the Java processes running on remote host including Tomcat as presented below.

All tabs including VisualGC on right hand site should now show appropriate graphs. See sample screen shot below: