0

Has anybody used the HQAPI to fetch the metrics of a resource programmatically? I want a sample code which uses the HQAPI to fetch the metrics of a resource.

Sajad Bahmani
  • 17,325
  • 27
  • 86
  • 108

3 Answers3

2

There is a treasure trove of examples here http://svn.hyperic.org/projects/hqapi/trunk/src/org/hyperic/hq/hqapi1/test/

and I am trying to put together some explanation here http://www.javamonamour.org/2012/05/creating-alert-recovery-with-hyperic.html

Pierluigi Vernetto
  • 1,954
  • 1
  • 25
  • 27
1

They seem to have plenty of examples on Github e.g.

https://github.com/hyperic/hqapi/blob/7b19d6b0ebfb8cfb2903d4a495ab0368ba3e6aeb/src/org/hyperic/hq/hqapi1/test/Metric_test.java

Also there is an example in their docs:

http://support.hyperic.com/display/DOC/HQApi+Java+API

Andrey Adamovich
  • 20,285
  • 14
  • 94
  • 132
0

The are actually a lot of ways you could do this:

  1. Run the plain old hqapi.sh resource list (or like) commands, which could be very slow.
  2. Paste directly in your browser window a restful URL:

    http://__host__:7080/hqu/hqapi1/alert/find.hqu?begin=1344004728555&end=1444004728999&count=100&severity=1&notFixed
    
  3. Use curl to achieve that:

    curl -u hqadmin "http://__host__:7080/hqu/hqapi1/alertdefinition/listDefinitions.hqu?resourceId=10201"
    
  4. I personally like using a scripting language like Python to do this.
  5. Then there is Groovy script, which you can run in a Groovy console under the administration tab. Check the hqapi1 hqu plugin.
Jamal
  • 763
  • 7
  • 22
  • 32
vHalaharvi
  • 179
  • 1
  • 10