6 Replies Latest reply on Mar 2, 2012 7:12 AM by Juergen Hoffmann

    Glassfish v2.1.1 Custom RHQ JMX Plugin

    Aurelio Calegari Newbie

      Hello,

       

      I'm trying to create a custom JMX plugin that collects some specific Glassfish metrics, such as connection pool metrics. Here's a sample of my rhq-plugin.xml:

       

       

      <?xml version="1.0" encoding="UTF-8" ?>

       

      <plugin name="TEST_JMX3"

              version="1.2"

              displayName="TestJMX_3"

              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

              xmlns="urn:xmlns:rhq-plugin"

              xmlns:c="urn:xmlns:rhq-configuration">

       

       

         <depends plugin="JMX"/>

       

         <service name="TestJMX_3"

                  description="A custom service representing a single custom MBean"

                  discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"

                  class="org.rhq.plugins.jmx.MBeanResourceComponent" supportsManualAdd="true" >

       

            <runs-inside>

               <parent-resource-type name="JMX Server" plugin="JMX"/>

            </runs-inside>

       

            <plugin-configuration>

                     <c:simple-property name="objectName" readOnly="true"

                                  default="amx:X-ServerRootMonitor=server,j2eeType=X-JDBCConnectionPoolMonitor,name=oe_pool"/>

            </plugin-configuration>

       

       

            <metric property="AverageConnWaitTime_Count"

                    displayName="AverageConnWaitTime_Count"

                    defaultOn="true"

                    category="performance"

                    description="Average wait time-duration per successful connection request"/> 

       

         </service>

       

      </plugin>

       

      When I manually import the JMX Server to my inventory I can see my plugin to be added as per the below printscreen:

      Screen shot 2011-02-03 at 11.28.33 AM.png

      I see the little drop down 'Manually Add:' and select that one and confirm the objectName page and get the follwing error in my screen:

       

      Unable to connect to the Agent. Cause: javax.ejb.EJBException:java.lang.RuntimeException: Error adding TestJMX_3 resource to inventory as a child of the resource with id 11571 - cause: Server specified unknown Resource type: ResourceType[id=10271, category=Service, name=TestJMX_3, plugin=TEST_JMX3] -> java.lang.RuntimeException:Error adding TestJMX_3 resource to inventory as a child of the resource with id 11571 - cause: Server specified unknown Resource type: ResourceType[id=10271, category=Service, name=TestJMX_3, plugin=TEST_JMX3] -> java.lang.IllegalStateException:Server specified unknown Resource type: ResourceType[id=10271, category=Service, name=TestJMX_3, plugin=TEST_JMX3]

       

      Screen shot 2011-02-03 at 11.31.20 AM.png

       

      This MBean is valid because I can manually inspect with eclipse:

       

              Map environment = new HashMap();

              String[] credentials = new String[] {"admin", "adminadmin"};

              environment.put (JMXConnector.CREDENTIALS, credentials);

       

              JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://hsn1007.hsntech.int:8686/jmxrmi");

       

              JMXConnector jmxc = JMXConnectorFactory.connect(url, environment);

       

              // Get MBean server connection

              MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

       

              ObjectName connPool = new ObjectName("amx:X-ServerRootMonitor=server,j2eeType=X-JDBCConnectionPoolMonitor,name=oe_pool");

       

              long averageCountWaitTime = (Long)mbsc.getAttribute(connPool, "AverageConnWaitTime_Count");

       

      Am I'm missing something here???

       

      Thanks

       

      Aurelio