How to get device uid based on host name in Zenoss API

891 Views Asked by At

I am new to Zenoss. I would like to know if there is any way to get the UID based on the device name. For example, in vCenter i have a VM with name 'MyTestVM' and i can see that in Zenoss Infrastructure section. I am developing a portal to show the monitoring graphs of CPU and Memory from zenoss. In order to do that i need to pass the UID to one of its API and i dont know how to get that UID of any device (VM specifically).

Any help here would be really helpful.

Regards, Kiran

PS: Please help me out if there is any confusion in this question.

1

There are 1 best solutions below

0
On

You have a few options, depending on what you need to.

The quick and ugly way, is to pull the UID, or UUID from your browser.

  1. navigate to the device details page under infrastructure/devices/...

  2. the UID should appear in your address bar. if the URL is "https://zenoss5.zenoss-host-name/zport/dmd/Devices/Server/Linux/devices/x.x.x.x/devicedetail#deviceDetailNav:device_overview" then your UID is "/zport/dmd/Devices/Server/Linux/devices/x.x.x.x"

you can also find the UUID by inspecting the page source and searching for "uuid"

The fun and more automatable way, is to use zendmd to look it up.

see the documentation here: support.zenoss.com: zendmd intro

  1. attach to your zope container, and su to the zenoss user.
  2. run zendmd
  3. Find the device using its name:

    In [1]: find('MyTestVM') Out[1]: <Device at /zport/dmd/Devices/Server/Linux/devices/x.x.x.x> In [2]: mydevice = find('MyTestVM') Out[3]: '3c5a857a-7d9f-4df9-bff9-2fcb9a07acbc'

  4. get the details you need from your dmd device:

    • UUID:

    In [3]: mydevice.getUUID() Out[3]: '3c5a857a-7d9f-4df9-bff9-2fcb9a07acbc'

    • ID:

    In [4]: mydevice.getId() OUT[4]: 'x.x.x.x'

The best way, is probably to use the JSON API.

there is a json api guide, and full API documentation