VMware Cloud Community
grqiu
Contributor
Contributor

Need help on Hyperic API, how to get a list of alerts?

I am new to Java and using Netbeans IDE 7.1.2, need to retrieve alerts based on time interval.

I added hqapi1-4.2.0.jar to the libraries of my Application project. I also added it as web service..

code:

package gethqalerts;
import java.io.IOException;
import org.hyperic.hq.hqapi1.HQApi;
import org.hyperic.hq.hqapi1.AlertApi;
import org.hyperic.hq.hqapi1.types.Alert;
import org.hyperic.hq.hqapi1.types.AlertsResponse;
import org.hyperic.hq.hqapi1.types.Response;
import org.hyperic.hq.hqapi1.types.ResponseStatus;

public class GetHQAlerts {

    /**

     * @param args the command line arguments

     */

    public static void main(String[] args) {

            HQApi api = new HQApi("10.2.3.7", 7080, false, "hqadmin", "hqadmin");

            try

            {

                AlertApi alertapi = api.getAlertApi();

                AlertsResponse alertRes = alertapi.findAlerts(1336713917, 1337713917, 1, 3, true, false);

                System.out.println("result is " + alertRes.getAlert().get(0).getName());

            }

            catch (IOException err)

            {

                System.out.println(err.getMessage());

            }       

    }

When trying to test and run, i got this error:

run:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/Credentials

at org.hyperic.hq.hqapi1.HQApi.<init>(HQApi.java:65)

at gethqalerts.GetHQAlerts.main(GetHQAlerts.java:25)

Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.Credentials

My Goal was to :

to export alerts into a database so that we can merge with other alerts from other systems. Perhaps there's a better/faster way???

any help would be appreciated.

thanks

Grace

0 Kudos
1 Reply
Texiwill
Leadership
Leadership

Hello,

Your post was moved to the Hyperic Developer FOrums.

Best regards,
Edward L. Haletky
VMware Communities User Moderator, VMware vExpert 2009, 2010, 2011, 2012

Author of the books 'VMWare ESX and ESXi in the Enterprise: Planning Deployment Virtualization Servers', Copyright 2011 Pearson Education. 'VMware vSphere and Virtual Infrastructure Security: Securing the Virtual Environment', Copyright 2009 Pearson Education.

vSphere Upgrade Saga -- Virtualization Security Round Table Podcast -- The Virtualization Practice

--
Edward L. Haletky
vExpert XIV: 2009-2023,
VMTN Community Moderator
vSphere Upgrade Saga: https://www.astroarch.com/blogs
GitHub Repo: https://github.com/Texiwill
0 Kudos