7 Replies Latest reply on May 14, 2013 5:03 AM by lkrejci

    How to get total alerts value from RHQ

    udayatom

      Hello friends,

       

                                I need to get the total alert counts. how can i get it.

       

       

       

       

      Regards,

       

      Udaya

        • 1. Re: How to get total alerts value from RHQ
          jayshaughnessy

          From the GUI I believe if you go to Reports->Alerts you should see the total count of alerts at the bottom right.  For specific resource or groups you'd see the same from that view.

           

          From the CLI you could perform a findAlertsByCriteria(AlertCriteria criteria) call, specifying any constraints you like.  You can specify criteria.setRestriction(Restriction.COUNT_ONLY) to just get the count and not fetch the data.

          • 2. Re: How to get total alerts value from RHQ
            udayatom

            thanks jay, I want to get the values in plugin can i get it through any function??

            • 3. Re: How to get total alerts value from RHQ
              mazz

              Agent plugins know nothing about alerts. In fact, the agent itself knows nothing about alerts. All alerting is done on the server-side.

               

              Nothing in the RHQ database is accessible to the agent plugins - the only thing the agent plugins are responsible for is managing and monitoring their respective resources and as such simply need to only report up-to-date information (current metric data, current availability data, current events, current configuration). The RHQ Server will handling all database access and will perform things like alert notification and storage.

               

              This was done on purpose - we do not provide an API to the plugins that gives them the ability to talk back to the server for the purposes of querying the database (thus avoiding custom agent plugins from doing things they shouldn't that would increase load on the server and database and thus negatively impact performance).

               

              That said, if you really, absolutely want to do this (and I would ask that you question your need for this) - obviously you can. But it is not recommended and we won't provide any API to make it easier because we discourage it. You could, for example, package the RHQ CLI/remote client jars in your own plugin and make RHQ remote client calls. Of course, your plugin will need username/password credentials to log into your RHQ Server (so you'd have to pass your RHQ credentials to your plugin somehow, either hardcode it or put them in plugin configuration property in your plugin). Again, none of this is recommended and is highly discouraged (and I never tried it, so it may not even work, though I can't think of why it wouldn't work). If you do something like this, you are essentially on your own, because its probably going to end up causing problems (I'm thinking performance problems in your RHQ Server, and perhaps in your RHQ agent as well, will crop up if you do this).

              • 4. Re: How to get total alerts value from RHQ
                jayshaughnessy

                I agree with mazz.  I would question the motivation for this in your plugin design.  But if you have to do it then that is the way to communicate from plugin to rhq server.  As an aside, the RHQ Server plugin has an "Alert Subsystem" service resource, although it does not report on alert counts, it is more related to inspecting alert condition matching statistics.

                • 5. Re: How to get total alerts value from RHQ
                  udayatom

                  Thanks you guys. very effective explanation.

                  • 6. Re: How to get total alerts value from RHQ
                    udayatom

                    This is my attempt to the CLI, As i am followed your CLI script, but i get the output     "UNDEFINED"  i worked as follow

                     

                     

                    var criteria=new AlertCriteria()

                    var resources=AlertManager.findAlertsByCriteria(criteria)

                    var x=criteria.setRestriction(Criteria.Restriction.COUNT_ONLY)

                     

                    how to get the values.

                    • 7. Re: How to get total alerts value from RHQ
                      lkrejci

                      var criteria = new AlertCriteria

                      criteria.setRestriction(Criteria.Restriction.COUNT_ONLY)

                      var alertCount = AlertManager.findAlertsByCriteria(criteria).totalSize;