If you are a Tomcat administrator, then you should be familiar with how to enable JMX in tomcat to monitor Heap Memory, Threads, CPU Usage, Classes, and configure various MBeans. In this article, I will talk about how to enable and connect to Tomcat with JConsole. I assume you have Tomcat installed if not; you can refer installation guide.

Go to path where you have Tomcat installed Go to bin folder Create a file as “setenv.sh” Modify file using vi editor and add following

Save the file with “:w” Change the file permission as executable

Before you start Tomcat to verify JMX, let’s take a look at the above configuration. Let’s start the tomcat by startup.sh script file. Once started, you can verify either using netstat or ps –ef grep command.

To verify using netstat

netstat –anlp | grep 9000 

To verify using ps command

ps –ef |grep jmx This concludes jmx is enabled in Tomcat and it’s time to connect using JMX client. You may use any client, however, to show you I will use jconsole, which comes with java.

Connect Tomcat JMX using Jconsole

Go to the path where you have jconsole

Tip: you may use the find command to search if you are not sure.

Execute jconsole

This will popup Java Monitoring & Management Console.

Select “Remote Process” Enter the server host and port details

Click on “Connect”

This will connect to Tomcat and show you very nice graphs of CPU, Memory & Thread usage. This becomes very handy during troubleshooting.

You may also perform GC from the console.

Click on Memory tab, and you will see “Perform GC” button

As mentioned at the beginning of the article, you may also configure MBeans for the classes. This is often used if you have to change the logging or specific parameters at runtime. So go ahead and play around with Jconsole and JMX. It’s a wonderful tool for troubleshooting and monitoring. If you are interested in learning more about Tomcat, then check out this tutorial.

How to Enable JMX in Tomcat to Monitor   Administer - 17How to Enable JMX in Tomcat to Monitor   Administer - 88How to Enable JMX in Tomcat to Monitor   Administer - 17How to Enable JMX in Tomcat to Monitor   Administer - 26How to Enable JMX in Tomcat to Monitor   Administer - 90How to Enable JMX in Tomcat to Monitor   Administer - 31How to Enable JMX in Tomcat to Monitor   Administer - 79How to Enable JMX in Tomcat to Monitor   Administer - 52How to Enable JMX in Tomcat to Monitor   Administer - 55How to Enable JMX in Tomcat to Monitor   Administer - 30How to Enable JMX in Tomcat to Monitor   Administer - 71How to Enable JMX in Tomcat to Monitor   Administer - 19How to Enable JMX in Tomcat to Monitor   Administer - 41How to Enable JMX in Tomcat to Monitor   Administer - 26How to Enable JMX in Tomcat to Monitor   Administer - 90How to Enable JMX in Tomcat to Monitor   Administer - 24How to Enable JMX in Tomcat to Monitor   Administer - 81How to Enable JMX in Tomcat to Monitor   Administer - 44How to Enable JMX in Tomcat to Monitor   Administer - 73How to Enable JMX in Tomcat to Monitor   Administer - 3How to Enable JMX in Tomcat to Monitor   Administer - 75How to Enable JMX in Tomcat to Monitor   Administer - 6How to Enable JMX in Tomcat to Monitor   Administer - 1How to Enable JMX in Tomcat to Monitor   Administer - 55How to Enable JMX in Tomcat to Monitor   Administer - 13How to Enable JMX in Tomcat to Monitor   Administer - 91