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

    Glassfish v2.1.1 Custom RHQ JMX Plugin

    aureliocalegari

      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

        • 1. Glassfish v2.1.1 Custom RHQ JMX Plugin
          mazz

          From this:

           

          java.lang.IllegalStateException:Serverspecified unknown Resource type: ResourceType[id=10271,category=Service, name=TestJMX_3, plugin=TEST_JMX3]

           

          I am guessing that the agent does not have your new plugin. Did the agent update its plugins? I would go to the agent prompt and issue the prompt command "plugins update" and then see what happens. From the agent prompt, you can also do a "plugins info" to see what plugins the agent already had (or just look in the agent's /plugins directory and see if the .jar file's md5 matches that which the server has).

           

          In addition, you might want to go look at the agent's log file to see what, if any, error messages show up that can further help pin point the problem.

          • 2. Glassfish v2.1.1 Custom RHQ JMX Plugin
            aureliocalegari

            Hi John,

             

            That was the problem! I The agents didn't seem to automatically update the plugin but once I performed the above instructions it all worked! All fixed and smoothly running!

             

            Cheers

             

            Aurelio

            • 3. Glassfish v2.1.1 Custom RHQ JMX Plugin
              pilhuhn

              Aurelio,

              this is very cool - I wonder if you would like to contribute your work to RHQ project

               

                Heiko

              • 4. Glassfish v2.1.1 Custom RHQ JMX Plugin
                aureliocalegari

                Hi Heiko,

                 

                Sure, why not. Still have to improve the plugin a bit and it's not a complete one. We're just monitoring JDBC Connection Pools and HTTP Threads. Maybe I could start a full fledged glassfish plugin from scratch! Just need to get some more plugin readings to make it as fancy as the JBossAS.

                 

                Cheers

                 

                Aurelio

                • 5. Glassfish v2.1.1 Custom RHQ JMX Plugin
                  pilhuhn

                  Aurelio,

                   

                  a full featured Glassfish plugin with discovery via process scan etc. would be totally great.

                   

                  To get started you can have a look at this "How to write a plugin" whitepaper.

                  Other things that will be very helpful:

                  • Plugin Generator
                  • Standalone Plugin Container

                   

                  The videos page on rhq-project.org features a few videos that talk about plugin development.

                   

                  Ping me if you need help (and join us on irc on irc://irc.freenode.net/#rhq )

                  • 6. Re: Glassfish v2.1.1 Custom RHQ JMX Plugin
                    juhoffma

                    Hi Aurelio,

                     

                    did you make any progress with the plugin creation yet? If not, I would like to get a look into what you have done. And then extend it to make it work with v3 maybe. Give me a poke if you are interested.