Wednesday, April 25, 2012

Hyperic, exploring (and exporting) autodiscovered resources with HQApi

http://support.hyperic.com/display/DOC/HQApi+3.2+resource+command


List details of a platform (machine)

cd C:\pierre\workspace\Hyperic\lib\hqapi1-client-5.0.0\bin
hqapi resource list -platform myhost.acme.com

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResourcesResponse>
    <Status>Success</Status>
    <Resource id="11328" name="myhost.acme.com" description="Red Hat Enterprise Linux 5"
location="" instanceId="10003" typeId="1">
        <ResourcePrototype resourceTypeId="1" instanceId="10001" id="10001" name="Linux"/>
        <Agent id="10003" address="10.58.25.132" port="2144" version="4.6.5" unidirectional="false"/>

        <Ip address="10.58.25.132" mac="34:8E:99:27:FD:80" netmask="255.255.255.0"/>
        <Ip address="127.0.0.1" mac="00:00:00:00:00:00" netmask="255.0.0.0"/>
        <ResourceInfo key="fqdn" value="myhost.acme.com"/>
    </Resource>
</ResourcesResponse>



List all details of a all Linux platforms (machine)

hqapi resource list -prototype Linux

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResourcesResponse>
    <Status>Success</Status>
    <Resource id="10882" name="myhost1.acme.com" description="Red Hat Enterprise Linux 5"
location="" instanceId="10001" typeId="1">
        <ResourcePrototype resourceTypeId="1" instanceId="10001" id="10001" name="Linux"/>
        <Agent id="10001" address="10.56.5.191" port="2144" version="4.5.3" unidirectional="false"/>

        <Ip address="10.56.53.191" mac="99:8E:99:27:FD:98" netmask="255.255.255.0"/>
        <Ip address="10.56.53.174" mac="99:8E:99:27:FD:98" netmask="255.255.255.0"/>
        <Ip address="127.0.0.1" mac="00:00:00:00:00:00" netmask="255.0.0.0"/>
        <ResourceInfo key="fqdn" value="myhost1.acme.com"/>
    </Resource>

    <Resource id="10883" name="myhost2.acme.com" description="Red Hat Enterprise Linux 5"
location="" instanceId="10002" typeId="1">
        <ResourcePrototype resourceTypeId="1" instanceId="10001" id="10001" name="Linux"/>
        <Agent id="10001" address="10.56.5.192" port="2144" version="4.5.3" unidirectional="false"/>

        <Ip address="10.56.53.191" mac="99:8E:99:27:FD:98" netmask="255.255.255.0"/>
        <Ip address="10.56.53.174" mac="99:8E:99:27:FD:98" netmask="255.255.255.0"/>
        <Ip address="127.0.0.1" mac="00:00:00:00:00:00" netmask="255.0.0.0"/>
        <ResourceInfo key="fqdn" value="myhost.acme.com"/>
    </Resource>
</ResourcesResponse>



Something really fantastic is when you do:

hqapi resource list -prototype Linux --children > myresources.xml

this will dump the ENTIRE database of resources!

And the real great thing is that you can
resource sync --file myresources.xml

to import into a HQ Server the resources exported by "resource list"

No comments: