VMware vSphere

 View Only
Expand all | Collapse all

Accessible resources within a platform with the HQ API

  • 1.  Accessible resources within a platform with the HQ API

    Posted May 31, 2010 08:58 AM
    Hello,

    I am using the HQ API to build a custom monitoring tool in Java.
    So far I can easily acces the agents and its related metrics.

    My problem is that I don't know how to access the resources related to the agent: fileserver mount, servers, services... Is it impossible with the HQ API??

    How can I do it?


  • 2.  RE: Accessible resources within a platform with the HQ API

    Posted May 31, 2010 10:06 AM
    So far I spent most of my time in the API JavaDoc. I've been looking also on the online documentation. And this is what I found:

    "The command-line tools expose a subset of the HQ APIs full functionality. The tools call the APIs, so any functionality available in the command-line tools is supported by the Java APIs themselves. The Java APIs provide additional functionality, for instance, richer functions for extracting metric data."

    So I didn't go further in the command-line tool and continue looking inside the API. Unsuccessfully.

    Do I have to use the command-line tool? Can I use it from my JAVA program?


  • 3.  RE: Accessible resources within a platform with the HQ API

    Posted May 31, 2010 01:59 PM
    he Alexis,
    You can use your Java IDE just fine. I develop my Hyperic plugin's within Eclipse.
    I use existing plugin's as a guide to develop new one's.

    My problem is that I don't know how to access the resources related to the agent: fileserver mount, servers, services... Is it impossible with the HQ API??


    I am not realy sure what you mean by that. But if you mean accessing the server/services of the application you want to monitor that is possible you should implement the Detector interface and detect your application. This can be done with Sigar see:
    http://support.hyperic.com/display/DOC/Auto+Inventory+Plugin and
    http://support.hyperic.com/display/SIGAR/PTQL
    for a little more information.
    You could also look at the MySql_stats or tomcat plug-in. The source for these can be found in the source code for Hyperic. You can get the Hyperic source here:
    http://svn.hyperic.org/projects/hq

    There is a small tutorial to make Hyperic detect new applications found here:
    http://support.hyperic.com/display/hypcomm/Hyperic+Custom+Auto-Discovery+Plug-ins

    I hope this helps you a little


  • 4.  RE: Accessible resources within a platform with the HQ API

    Posted May 31, 2010 03:49 PM
    I mean that I can access the different agents. This allows me to see the availability, the CPU Usage and the swap of the corresponding machine for example.

    But when I use the Hyperic dashboard, I can also see what is inside this machine: servers and services. This way I can see the Tomcat availability, the Disk space...

    For those information, I have to build a specific plugin? I am surprised that this function is not included. Without plugins, the API would be a little limited...

    During my research, I found something like Resource.getChild() but this is for HQU. Is it what I have to use to build my plugin? I will check the links you sent me and the documentation about plugins.


  • 5.  RE: Accessible resources within a platform with the HQ API

    Posted Jun 01, 2010 08:08 AM
    I don't think i need to build an Autodiscovery plugin. All the resources I want appear correctly in the Hyperic UI. So it is not a problem of discovery.

    The problem is to explore those resources, with the API :
    I can access the agents;
    From the agents I can access the platform Resource (Win32 platform) ;
    And now I want to access the disks, servers and services (JBoss, TomCat, MySQL) from the platform.

    But I cannot find the method in the API.

    Do I still need a plugin for that? Did I miss something in the Javadoc?


  • 6.  RE: Accessible resources within a platform with the HQ API

    Posted Jun 01, 2010 01:07 PM
    Hi Alexis,

    There are 2 getResources() APIs in Resource API that should be able to do what you want. One will return all Resources based on an Agent object, and the other will return all Resources for a platform name. You'll just need to make sure you pass true for the children argument.

    -Ryan


  • 7.  RE: Accessible resources within a platform with the HQ API

    Posted Jun 02, 2010 08:40 AM
    First thank you for this answer.
    Indeed now I can access directly those "inner resources" (tomcat, mySql,...). I use getResources(ResourcePrototype pt, boolean verbose, boolean children). By the way, whatever if I set children to true or false it always returns the same number of resources
    .
    The method getPlatformResource(java.lang.String name, boolean verbose, boolean children) only returns the platform resource with the corresponding name. It returns only one resource. Not its children.
    So I cannot find the method you are talking about: the other will return all Resources for a platform name.

    Now here is my problem:
    - with a first method, I can access my machines using getResources with an agent.
    - with the 2nd method, I can access my services (tomcat, mySql,...). using getResources with a ResourcePrototype.
    But I need to identify where this resource is coming from. The agent field and the IP field of the resource are empty. And the Name field is not a reliable identifier.
    How can I make the link between my services and my machines?


  • 8.  RE: Accessible resources within a platform with the HQ API
    Best Answer

    Posted Jun 02, 2010 11:04 AM
    if u use this it will be very easy !

    //get all the agents of ur HQ Server :this will return a list of agents !

    listAgent=hq.getAgentApi().getAgents().getAgent();

    //get all the platform of ur HQ Server :this will return a list of Resources(platform)!

    listPlatform=hq.getResourceApi().getResources(listAgent.get(i),true,true).getResource();

    //get all the server of ur HQ Server:this will return a list of Resources(server)!

    listServer = listPlatform.get(j).getResource();

    //get all the services of ur HQ Server : this will return a list of Resources(services)!

    listServices = listServer.get(k).getResources();

    with this u can have the agent (ur machines) and all Resources under it !!!

    Hope this will help u


  • 9.  RE: Accessible resources within a platform with the HQ API

    Posted Jul 13, 2010 08:36 AM
    Hi Alexis,

    Did you find how to make the link between services and machines ?

    This would help me.

    Thks


  • 10.  RE: Accessible resources within a platform with the HQ API

    Posted Jul 13, 2010 02:24 PM
    The previous post was the solution:

    if u use this it will be very easy !
    //get all the agents of ur HQ Server :this will return a list of agents !
    listAgent=hq.getAgentApi().getAgents().getAgent();

    //get all the platform of ur HQ Server :this will return a list of Resources(platform)!
    listPlatform=hq.getResourceApi().getResources(listAgent.get(i),true,true).getResource();

    //get all the server of ur HQ Server:this will return a list of Resources(server)!
    listServer = listPlatform.get(j).getResource();

    //get all the services of ur HQ Server : this will return a list of Resources(services)!
    listServices = listServer.get(k).getResources();

    with this u can have the agent (ur machines) and all Resources under it !!!
    Hope this will help u


    Using getRessources() on the server within your machine/platform will return all ressources concerning this machine/platform.

    Then you can find the network services within the Network Services ressource. For this, you can first test the ressource name and then use Ressource.getRessources() to access the network services.

    Does that answer your question?


  • 11.  RE: Accessible resources within a platform with the HQ API

    Posted Jul 15, 2010 09:59 AM
    > Does that answer your question?

    Indeed it does !

    Thanks Alexis


  • 12.  RE: Accessible resources within a platform with the HQ API

    Posted Jul 15, 2010 02:33 AM
    Maybe. I did miss it too at first.

    If you check the Resource class, you will see there is a method called getResource() which returns a list of resources included in the current resource.

    This allows you to go deeper and deeper in the system.

    So once you acces your platform, through the agent or directly, whatever, getResource() returns you the server on this machine (as a list): Win32 for example.

    On this server, getResource() will return a bunch of resources including applications, databases... And also "folder" resources. For example, FileMount Server contains the list of hard drive you have on the machine. And Network Services contains the network service resources.