A. JMX Mission Control
Oracle Java Mission Control enables you to monitor and manage Java applications without introducing the performance overhead normally associated with these types of tools. It uses data collected for normal adaptive dynamic optimization of the Java Virtual Machine (JVM). Besides minimizing the performance overhead, this approach eliminates the problem of the observer effect, which occurs when monitoring tools alter the execution characteristics of the system.
1. Server setup
> Provide the JMX configuration to Tomcat server > Create a setenv.sh file in $CATALINA_HOME/bin > Add the following entry to the script file export CATALINA_OPTS="-Dcom.sun.management.jmxremote=true \ -Dcom.sun.management.jmxremote.port=3614 \ -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.autodiscovery=true" > This will enable JMX listener on port 3614 when tomcat is restarted > Make sure that this port is open and accessible to outside world. This may have security concerns hence its not advisable for production environment. > Restart the server to allow the properties to be set and initialized.
2. Mission Control setup
Download: mission control In my test I had used an eclipse plugin available at http://download.oracle.com/technology/products/missioncontrol/updatesites/base/5.5.0/eclipse/ > Just added this plugin to the eclipse using Install new Software > Launch a new connection to the JVM and provide the IP and port on which the jmx remote system is running.
B. Alternate way is to use VisualVM
VisualVM is a visual tool integrating several commandline JDK tools and lightweight profiling capabilities.
Here as well we need to start jstatd daemon on the server which opens up connections for the visualvm client and is packaged with the JDK.
Download: http://visualvm.java.net/download.html Reference: https://visualvm.java.net/applications_remote.html
1. Start the jstatd daemon
> Make sure the default RMI port is open as per the javase documentation > Create a policy file named jstatd.all.policy and copy the following content to it grant codebase "file:${java.home}/../lib/tools.jar" { permission java.security.AllPermission; }; > Start the daemon jstatd -J-Djava.security.policy=jstatd.all.policy > Alternate option to run this silently nohup jstatd -J-Djava.security.policy=jstatd.all.policy &>/dev/null &
2. Start the VisualVM Client
> Start the Visual VM client and add remote host using its IP > You will be able to monitor the jvm on that machine