7 Replies Latest reply on Jan 21, 2011 7:08 AM by pilhuhn

    Consume cpu too much!


      I write six agent-plug-ins. The agent-plugin will invoke MBean Services first.


      But the usage of cpu is astonished me . The agent consumed  more than one core.


      There are four cpus in the agent computer, and we will monitor the jboss as and services.


      I write MBean service get data from jboss like invoke the esb .



      Are there ways to down the usage of the cpu?



        • 1. Re: Consume cpu too much!

          The first thing to check is your metrics collection schedules. If you collect too many metrics with too short intervals, you obviously are going to stress the system more than if you check for metrics once an hour for example.

          The CPU usage is usually not a problem with the agent so if the above doesn't work, I'd check the configurations of your plugins or hook up a profiler to the agent and examine what methods inside the agent use the most CPU.

          • 2. Consume cpu too much!

            Thanks for your replying.

            The metrics shedules is the default , I didn't change it .

            I think there are not special configuration in my plugins.

            • 3. Consume cpu too much!


              it is hard to answer here, as we don't know your code.

              You should make sure, that when getting metrics, you don't go to the MBeanServer for each one, but bundle them together to refresh/read all attributes of an MBean at once and process internally.

              • 4. Consume cpu too much!


                It's true when I getting the metircs , I invoke MBean in MBeanServer locally.


                How I bundle them together ? Should I encapsulationthe metrics to a object ?

                Invoking MBean consuming  too much cpu?


                Thanks again.

                • 5. Consume cpu too much!



                  again, as long as I don't know your code, everything I say is pure speculation.


                  Are you using the JXM plugin as base of your work? Or are you writing the code on your own? Can you post snippets?


                  Even with local connections, this could become an issue when you e.g. are not caching the MBeanServer connection.


                  getValues(Requests..) is basically doing


                  for (Request : Resuests) {

                     Attribute = determineAttributeFromRequest()




                  The incoming Requests are not necessarily all going to the same MBean.

                  If you now would do:

                  askMBeanServerForValue(Attribute) {







                  you could end up with a lot of processing which may end up in high cpu usage.


                  But then again, this is pure speculation, as I don't know your code.

                  • 6. Consume cpu too much!

                    Thanks .

                    Yes , I did not close the EmsConnection.

                    Because I get the emsConnection  from ApplicationServerComponent.


                    ApplicationServerComponent as = ((ApplicationServerComponent) context.getParentResourceComponent());

                        emsConnection = as.getEmsConnection();


                    Will I close the connection?

                    I think the connection managed by ApplicationServerComponent , If I close the connection , whether I affect the applicationServerComponent?




                    Thanks very much.

                    • 7. Consume cpu too much!


                      that code snippet looks good as far as I can see - and no it does not close the connection.


                      I think the Hibernate plugin ( http://git.fedorahosted.org/git/?p=rhq/rhq.git;a=tree;f=modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate )

                      is a nice small example of a plugin that uses jmx and can run inside the JBossAS.

                      Another one is the JBossCache plugin ( http://git.fedorahosted.org/git/?p=rhq/rhq.git;a=blob;f=modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java  )


                      Did you try to hook up a profiler and to see where the CPU is used?

                      To hook up a profiler, you could run the plugin in the standalone container (see e.g.  Using the standalone container for development )


                      Hope this helps you further.