3 Replies Latest reply on Feb 17, 2010 3:10 PM by Paul Ferraro

    Exposing load metrics via JMX

    Marek Goldmann Master

      Hi,

       

      I'm trying to get load metrics values via JMX. I cannot see getLoad() method to be exposed in a load metric bean.

       

      How can I obtain load let's say for BusyConnectorsLoadMetric via JMX?

       

      Thanks!

        • 1. Re: Exposing load metrics via JMX
          Paul Ferraro Master

          At the moment, you cannot fetch individual load values via JMX.  The getLoad(...) method on LoadMetric requires a LoadContext.  Consequently, this is not usable as a mbean method.  With some work, however, you can achieve what you're looking for.

           

          First, extend the LoadMetricMBean interface with the following:

           

          {code}public interface MyLoadMetricMBean extends LoadMetricMBean

          {

            double getLoad();

          }{code}

           

          Next, extend the BusyConnectorsLoadMetric impl, and implement getLoad().

          We'll express this metric's load in terms of its capacity:

           

          {code}public class MyBusyConnectorsLoadMetric extends BusyConnectorsLoadMetric implements MyLoadMetricMBean

          {

            public MyBusyConnectorsLoadMetric() throws MalformedObjectNameException   {     super();   }

           

            public double getLoad()

            {

              MBeanQueryLoadContext context = this.getSource().createContext();

              try

              {

                return this.getLoad(context) / this.getCapacity();

              }

              finally

              {

                context.close();

              }

            }

          }{code}

           

          Now use the new load metric impl and mbean interface in your *-jboss-beans.xml config:

           

          {code:xml}<bean name="BusyConnectorsLoadMetric" class="org.jboss.modcluster.load.metric.impl.MyBusyConnectorsLoadMetric" mode="On Demand">

            <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=BusyConnectorsLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.MyLoadMetricMBean.class)</annotation>

          </bean>{code}

           

          On second thought, this seems like a useful method to expose via JMX.  I'll create a feature request.

          • 2. Re: Exposing load metrics via JMX
            Michael Neale Expert

            That looks like a really nice idea to bake in. Does any one know how JOPR manages to dig this out:

             

            For example: http://www.jopr.org/display/JOPR2/Web+Application+(WAR)+Service#WebApplication%28WAR%29Service-Metrics

            (just want to make sure there isn't an existing path for this data that we are missing).

            • 3. Re: Exposing load metrics via JMX
              Paul Ferraro Master

              It looks like Jopr uses the same JMX-based mechanism as mod_cluster to detect connector thread busyness:

              http://www.jopr.org/display/JOPR2/Tomcat+Connector+Service

               

              BTW - I've created a feature request for this topic:

              https://jira.jboss.org/jira/browse/MODCLUSTER-130