vCenter

 View Only
  • 1.  Question about Hyperic HQ API

    Posted Mar 19, 2008 06:12 PM
    I am currently writing an application that wants to access the metrics from hyperic HQ.
    I have Hyperic server and agents installed. I want my application to use some sort of API from hyperic HQ so that my application can automatically get the metrics generated and do some other stuff with it.

    When I look at the documentation it says that there is a Groovy API and Back-End API.

    How do I use the back-end API? Do I need to compile my application together with the source code of hyperic hq? Is there a JAR file that I can just include when I compile my application?

    Message was edited by: rold50


  • 2.  RE: Question about Hyperic HQ API

    Posted Mar 19, 2008 11:22 PM
    The API isn't fully released yet - however, if you want in one week, Jon Travis, Hyperic engineer extraordinaire will walk through this whole API in next week's HyperCAST when it debuts on March 26th. To sign up, go to http://www.hyperic.com/demo/hypercasts.html - also note we are moving it from the regular Tuesday slot to Weds to coordinate better with the release. John Mark should be updating that later tonight.


  • 3.  RE: Question about Hyperic HQ API

    Posted Mar 27, 2008 12:47 AM
    Hi Stacey,

    I watched the hypercast, but sadly it didn't address what I need.

    Basically, I am not creating a plug-in. I am thinking of having the following set up:
    I have Hyperic HQ agent and server installed. I am only interested in getting the metric data. For example, as a user I can use the CLI and get the metric. What I am trying to do is have a separate program that gets the metric from Hyperic every few minutes. For example, if the metric from Hyperic, returns a CPU util% of some value, I want my program to do some tasks. That is why I am asking if there is some sort of API that I can use to get the metric from Hyperic? The other way I was thinking is to have my program run a shell script and run the CLI of Hyperic to get the metrics and then have my program parse the results of the CLI. However, I think if there is an API that I can use, my code will be cleaner.

    I looked at the Hyperic PDK, and there is a library called hq-product.jar. Is that an API that I can use for my separate program? Are there documentations of what functions/methods I can use from hq-product.jar?




    -Harold


  • 4.  RE: Question about Hyperic HQ API

    Posted Mar 27, 2008 04:00 PM

    Greetings,

    I'm not sure which HyperCAST you watched, but With the just-released HQU
    API, you can pull that type of info from HQ with an HTTP request.

    I would start here:
    http://support.hyperic.com/confluence/display/hypcomm/HQU+Documentation

    And in particular, this one:
    http://support.hyperic.com/confluence/display/hypcomm/HQU+XML+Web+Services

    We're putting examples at http://www.hquplugins.org/

    Thanks,
    John Mark


    Excerpts from Roger Symonds [CustomWare]'s message of Wed Mar 26 17:46:39 -0700 2008:
    > Hi Stacey,
    >
    > I watched the hypercast, but sadly it didn't address what I need.
    >
    > Basically, I am not creating a plug-in. I am thinking of having the following
    > set up:
    > I have Hyperic HQ agent and server installed. I am only interested in getting
    > the metric data. For example, as a user I can use the CLI and get the metric.
    > What I am trying to do is have a separate program that gets the metric from
    > Hyperic every few minutes. For example, if the metric from Hyperic, returns a
    > CPU util% of some value, I want my program to do some tasks. That is why I am
    > asking if there is some sort of API that I can use to get the metric from
    > Hyperic? The other way I was thinking is to have my program run a shell script
    > and run the CLI of Hyperic to get the metrics and then have my program parse
    > the results of the CLI. However, I think if there is an API that I can use, my
    > code will be cleaner.
    >
    > I looked at the Hyperic PDK, and there is a library called hq-product.jar. Is
    > that an API that I can use for my separate program? Are there documentations of
    > what functions/methods I can use from hq-product.jar?
    >
    >
    >
    >
    > -Harold



  • 5.  RE: Question about Hyperic HQ API

    Posted Mar 27, 2008 09:18 PM
    Hi John Mark,

    Just to clarify, with the just released HQU, can I just make my application have an http request to HQ server to get the info I need? I don't have to write a plugin anymore?

    I was looking at the API, and most of them are talking about creating a plugin using groovy. However, that is not what I want. Since I already have a separate java application. I just want to add some code in my java application that cn pull info from HQ.


    Thanks,
    Harold


  • 6.  RE: Question about Hyperic HQ API

    Posted Mar 31, 2008 10:27 PM
    This is probably best done using the web services. I'd look at the OpenNMS integration examples to do what you are after - Travis covered this as an option, but he did not indeed go through the details on writing the web services.


  • 7.  RE: Question about Hyperic HQ API

    Posted Mar 31, 2008 10:39 PM
    Harold,

    You don't need to compile anything. However, your request was to
    have HQ just give you 'the info I need'. What info is that? metric
    data? Over what time range? What granularity? For which resources?

    Perhaps your request is generic, perhaps it isn't. Regardless, HQU
    is meant to make it easy for you to export whatever data you want
    from HQ to your application.

    You will, however, need to do a little legwork. It won't just
    'export the info you need' via magic.

    To get your data into your app, just have your app make an HTTP
    request to HQ (plenty of examples for that included on
    hquplugins.org, in the shell scripts). That HTTP request needs to
    correspond with the HQU plugin on the HQ side of things.

    -- Jon




    On Mar 27, 2008, at 2:18 PM, rold50 wrote:

    > Hi John Mark,
    >
    > Just to clarify, with the just released HQU, can I just make my
    > application have an http request to HQ server to get the info I
    > need? I don't have to write a plugin anymore?
    >
    > I was looking at the API, and most of them are talking about
    > creating a plugin using groovy. However, that is not what I want.
    > Since I already have a separate java application. I just want to
    > add some code in my java application that cn pull info from HQ.
    >
    >
    > Thanks,
    > Harold




  • 8.  RE: Question about Hyperic HQ API

    Posted Apr 01, 2008 02:42 AM
    Hi Jon,

    Thanks for the reply.

    I'm looking for a metric for Jboss. For example, the hyperic HQ agent, has a plugin that gives us the metric for jboss. in command line, I can do something like this to each agent: java -jar pdk/lib/hq-product.jar -p jboss -m metric
    It will give some output like:
    JBoss 4.0 JMS Message Cache Size:
    ... etc...

    What I want is to do an http request to the HQ server and give me a similar data from above from all the agents in an xml format.

    Is there a way for groovy plugin to gather all the info from all the agents? I see that there is a MetricHelper.groovy API. Is that what I need to use if I want to write a plugin that returns info like I mentioned above? I'm not really sure how to use the MetricHelper groovy.

    Message was edited by: rold50


  • 9.  RE: Question about Hyperic HQ API

    Posted Apr 01, 2008 06:21 PM
    Yes, what you want to do is definitely possible.

    The files you are mostly interested in are : ResourceHelper.groovy,
    and MetricCategory.groovy. The 'category' classes add methods to
    your classes, which are more intuitive.

    I created a small script that will dump out the last metric data
    point for each of the resources of a specific type (in this case,
    JBoss 4.0 JMS Destination).

    You can copy and paste the following code into your Groovy Console to
    see how to get metrics and convert it to XML. From there, it should
    be pretty easy to integrate with the rest of your plugin:

    > import org.hyperic.hq.hqu.rendit.util.HQUtil
    > import org.hyperic.hq.hqu.rendit.helpers.ResourceHelper
    > import groovy.xml.MarkupBuilder
    >
    > def overlord = HQUtil.overlord
    >
    > def rhelp = new ResourceHelper(overlord)
    > def prototype = rhelp.findResourcePrototype('JBoss 4.0 JMS
    > Destination')
    > def resources = rhelp.findResourcesOfType(prototype)
    >
    > def writer = new StringWriter()
    > def xml = new MarkupBuilder(writer)
    >
    > xml.resources() {
    > for (r in resources) {
    > xml.resource(name: r.name, id: r.id) {
    > for (metric in r.enabledMetrics) {
    > def metricData = metric.lastDataPoint
    > xml.metric(name: metric.template.name,
    > value: metricData.value,
    > time: metricData.timestamp)
    > }
    > }
    > }
    > }
    > writer.toString()
    >



    Results in:

    > <resources>
    > <resource name='Travistation.local JBoss 4.0 default DLQ JMS
    > Destination' id='10641'>
    > <metric name='Availability' value='1.0' time='1207073880000' />
    > <metric name='Messages in Queue' value='0.0'
    > time='1207073700000' />
    > <metric name='Receivers Count' value='0.0' time='1207073700000' />
    > </resource>
    > <resource name='Travistation.local JBoss 4.0 default
    > agentScheduleQueue JMS Destination' id='10640'>
    > <metric name='Availability' value='1.0' time='1207073880000' />
    > <metric name='Messages in Queue' value='0.0'
    > time='1207073700000' />
    > <metric name='Receivers Count' value='1.0' time='1207073700000' />
    > </resource>
    > <resource name='Travistation.local JBoss 4.0 default
    > monitorAlarmQueue JMS Destination' id='10639'>
    > <metric name='Availability' value='1.0' time='1207073880000' />
    > <metric name='Messages in Queue' value='0.0'
    > time='1207073700000' />
    > <metric name='Receivers Count' value='0.0' time='1207073700000' />
    > </resource>
    > </resources>



    -- Jon



    On Mar 31, 2008, at 7:42 PM, rold50 wrote:

    > Hi Jon,
    >
    > Thanks for the reply.
    >
    > I'm looking for a metric for Jboss. For example, the hyperic HQ
    > agent, has a plugin that gives us the metric for jboss. in command
    > line, I can do something like this to each agent: java -jar pdk/lib/
    > hq-product.jar -p jboss -m metric
    > It will give some output like:
    > JBoss 4.0 JMS Message Cache Size:
    > JBoss
    > 4.0:jboss.mq:service=MessageCache:TotalCacheSize:java.naming.provider.
    > url=jnp%3A//127.0.0.1%3A2099,java.naming.security.principal=%
    > java.naming.security.principal%,java.naming.security.credentials=%
    > java.naming.security.credentials%
    > =>0.0<=
    >
    > What I want is to do an http request to the HQ server and give me a
    > similar data from above from all the agents in an xml format.
    >
    > Is there a way for groovy plugin to gather all the info from all
    > the agents? I see that there is a MetricHelper.groovy API. Is that
    > what I need to use if I want to write a plugin that returns info
    > like I mentioned above? I'm not really sure how to use the
    > MetricHelper groovy.




  • 10.  RE: Question about Hyperic HQ API

    Posted Apr 01, 2008 06:58 PM
    Thanks Jon. This is really helpful.

    -Harold


  • 11.  RE: Question about Hyperic HQ API

    Posted Apr 02, 2008 05:40 PM
    I've posted the snippet from this thread on the hquplugins.org
    snippet section, for future reference.

    -- Jon


    On Apr 1, 2008, at 11:57 AM, rold50 wrote:

    > Thanks Jon. This is really helpful.
    >
    > -Harold