views:

356

answers:

2

Hi,

We have a Java web application and we'd like to set up some basic monitoring with a view to expanding this monitoring in future. Our plan is as follows:

(1) Collect generic information (e.g. memory and threads) about the virtual machine of the web container that application is running in.

(2) Monitor the "state" of the application. This is rather vague but at the least we'd like to see if the web application is still alive and can respond to requests.

(3) In the future we'd like to collect more information that is specific to our application. Again this is rather vague but you can assume that we might want to make certain statistics collected internally by the application available to the support staff.

Usually the web application will be deployed in a Tomcat 5.5 or 6 environment. A quick bit of searching on the web shows that JMX can be enabled for Tomcat and that JConsole can then be used to connect to the server. This gives us lots of basic information that solves point (1). Also, some information is available in the MBeans section for "Catalina" and drilling down on this I can at least, for example, see how many requests a particular servlet has received. This is not quite what we want for point (2) but at least gives us some information. There seems to be quite a lot of information there but it's rather difficult to interpret using JConsole. Perhaps there is a better tool for interpreting the MBeans exposed by Tomcat.

For point (3), it seems, at first glance that we could write our own MBeans and then make these available to something like JConsole. Personally, this would involve me learning about JMX which I'm quite happy to do but I have a concern. Having looked around I notice that most of the textbooks on the subject haven't been updated for several years and the open source tools seem to be languishing without recent updates. So my main question is a simple one. What are your opinions on JMX? Does it have a future or is it/has it been superseded by something else? Given we already have our web application but we're starting from scratch for the management console, should we choose JMX or is there something more appropriate with a better future ahead of it?

I ask this question with no personal axe to grind, I'm simply interested to hear your opinions and experiences. I'm sure there's no one correct answer but I think an informed discussion would be useful.

Thanks in advance,

Adam.

+5  A: 

JMX is certainly a good solution here. I wouldn't worry about it languishing. Most enterprises I've worked for recently use (or have plans to use) JMX, and I'd have to hear a pretty convincing argument before choosing something else in the Java world. It's easy to write clients (monitoring solutions) for it and you can return complex data very easily indeed. Most 3rd party components support monitoring via JMX as well.

Note that you may want to consider integration with any existing management solutions (e.g. Nagios, BNC Patrol, HP Openview etc.) as well. They may not be so Java-aware, but rather prefer tests like simple HTTP connectivity for testing if a web-site is up (easy using Nagios), or integration using SNMP (which Openview talks natively).

Brian Agnew
Thanks. It's good to hear your positive view on the future of JMX!
Adam
+1  A: 

If applicable to your situation (Java 6 update 10 JDK or later, plus on the same machine) then consider using jvisualvm instead as it can dig even deeper than JConsole.

You may find that the easiest way to do what you need is a plugin to jvisualvm knowing your application

Thorbjørn Ravn Andersen
JVisualVM sounds like a good idea. I presume the requirement for JDK 6 is only on the local machine running JVisualVM and does not apply to the JVM for the web application container.Given my point (2), do you know of a plugin to JVisualVM that makes it easier to read the basic MBean information provided by Tomcat?
Adam
Your life will be much much easier if you can run visualvm on the same host as the container as this allows access to unprepared JVM's. You can, however, do remote access with proper incantations to the JVM at startup. Java 6 works the best. Regarding JMX, add the VisualVM-MBeans plugin using Tools->Plugins (I've not tested recently but it worked a while back).
Thorbjørn Ravn Andersen
Thanks. I've tried the VisualVM-MBeans plugin and it seems to give basically the same view of the MBeans given by JConsole (which is, of course, better than nothing). Is anyone aware of a plugin specific to Tomcat?
Adam