Monday, December 3, 2012

Monitoring Tomcat with VisualVM

VisualVM is great tool that you can use to monitor and profile java applications. In this post I will explain how to use VisualVM to monitor Tomcat. You should never reconfigure Tomcat memory setup without first checking where is the problem.

Installing VisualVM

Download zip from website.  Unzip content into desired directory and run visualvm.exe

Monitoring Tomcat in Eclipse

Open launch configuration of Server that you wish to monitor and to VM Arguments add:
 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false   

Now if you start Tomcat can connect to it with VisualVM.

Monitoring Tomcat as a Windows Service

You should open Configuration Editor with:
 tomcat7w.exe //MS//  
and add:
 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false   
to Java Options

Monitoring Tomcat in standalone mode

Open catalina.bat or catalina.sh (depending on the environment) and add:
 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false   
to JAVA_OPTS.

Final Comment on VisualVM

If you want to monitor common java programs from eclipse you can install VisualVM launcher in eclipse. Details are described here.

Useful links

When problems with memory arise you can debug them using next two links:
http://www.skill-guru.com/blog/2010/09/23/how-to-increase-heap-size-in-tomcat-6/
http://www.skill-guru.com/blog/2010/10/05/increasing-permgen-size-in-your-server/