Runtime performance monitoring made easy

EtmMonitor JMX Howto

JETM provides means to expose an EtmMonitor through JMX. This page describes the necessary steps for manual registration, for Springframework based registration and automatic registration using a JETM plugin.

JMX support using JETM plugin

Whenever you are using static EtmManager configuration you can use the EtmMonitorJmxPlugin for JMX registration.

The following example enables JMX support for an EtmMonitor configuration and alters the MBean name to etm:service=PerformanceMonitoringService. If you don't provide this property the default name etm:service=PerformanceMonitor will be used. Internally this feature registers the EtmMonitorJmxPlugin mentioned above.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jetm-config PUBLIC "-// void.fm //DTD JETM Config 1.2//EN"
                             "http://jetm.void.fm/dtd/jetm_config_1_2.dtd">
<jetm-config>
  <features>
    ...
  
    <jmx monitorObjectName="etm:service=PerformanceMonitor"/>
  </features>

</jetm-config>

The plugin will also register all top level performance results as JMX beans.

JMX support using manual registration

Of course it is possible to register an EtmMonitor manually. Use the class EtmMonitorMBean to do so.

EtmMonitor monitor = ...;

ArrayList mbeanServers = MBeanServerFactory.findMBeanServer(null);
MBeanServer mbeanServer = (MBeanServer) mbeanServers.get(0);

if (mbeanServer != null) {

  ObjectName objectName = new ObjectName("etm:service=PerformanceMonitor");
  // register EtmMonitor using EtmMonitorMBean
  try {
    mbeanServer.registerMBean(new EtmMonitorMBean(monitor), objectName);
  }
}

JMX support using Spring Framework MBeanExporter

If you are using Spring for configuration management you can easily export any EtmMonitor instance using the Springframework class MBeanExporter. This class can export valid JMX MBeans to an MBeanServer by declaration or automatically.

The following configuration example exports all JMX MBeans including our EtmMonitorMBean using the JMX name etm:service=PerformanceMonitor. It assumes that your application runs within an JMX enabled infrastructure (such as JBoss, Tomcat or Bea Weblogic). For all other plattforms see spring MBeanExporter documentation.

<beans>

  <bean id="etmMonitor" class="etm.core.monitor.NestedMonitor"
        init-method="start" destroy-method="stop"/>

  <bean name="etm:service=PerformanceMonitor"
        class="etm.core.jmx.EtmMonitorMBean" autowire="constructor"/>

  <bean class="org.springframework.jmx.export.MBeanExporter">
    <property name="autodetect" value="true"/>
  </bean>

</beans>

Further notes

Accessing performance results via JMX is kind a awkward since everything pretty much depends on your JMX browser. For instance the Sun JDK JConsole will render strange performance results while the JBoss JMX console can be used as a replacement for our JETM HTTP Console.