Monday, October 29, 2007

JVM Monitoring using JMX

We can manage Java applications through JMX API. Java supports JMX from jdk1.5 onwards. JConsole is a tool for monitoring local or remote JVMs. This entirely works on JMX technology. To do what JConsole does we need to write a JMX client. This client would get access to the MBean exposed by JVM by connecting to the JMX Agent in that JVM.

How to write a client is explained clearly by this blog [1]. We can modify the code given in the blog to access the memory usage details of the JVM. We have to gain access to the MemoryMXBean[2].

There are some issues which have to be taken care of when running the application to be monitored.[3] The java application should be run using the following parameters:

The Remote Client connects to a JMX agent using an RMI connector with the following URL: [4] service:jmx:rmi:///jndi/rmi://hostName:5009/jmxrmi.