简体   繁体   English

如何在Zenoss API中基于主机名获取设备uid

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

I am new to Zenoss. 我是Zenoss的新手。 I would like to know if there is any way to get the UID based on the device name. 我想知道是否有任何方法可以根据设备名称获取UID。 For example, in vCenter i have a VM with name 'MyTestVM' and i can see that in Zenoss Infrastructure section. 例如,在vCenter中,我有一个名为“ MyTestVM”的VM,我可以在Zenoss基础结构部分中看到它。 I am developing a portal to show the monitoring graphs of CPU and Memory from zenoss. 我正在开发一个门户网站,以显示来自zenoss的CPU和内存的监视图。 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). 为了做到这一点,我需要将UID传递给它的API之一,而且我不知道如何获取任何设备(特别是VM)的UID。

Any help here would be really helpful. 这里的任何帮助将非常有帮助。

Regards, Kiran 问候,柯兰

PS: Please help me out if there is any confusion in this question. PS:如果这个问题有任何困惑,请帮助我。

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. 快速且丑陋的方法是从浏览器中提取UID或UUID。

  1. navigate to the device details page under infrastructure/devices/... 导航到基础架构/设备/ ...下的设备详细信息页面

  2. the UID should appear in your address bar. UID应该出现在您的地址栏中。 if the URL is " https://zenoss5.zenoss-host-name/zport/dmd/Devices/Server/Linux/devices/xxxx/devicedetail#deviceDetailNav:device_overview " then your UID is "/zport/dmd/Devices/Server/Linux/devices/xxxx" 如果URL为“ https://zenoss5.zenoss-host-name/zport/dmd/Devices/Server/Linux/devices/xxxx/devicedetail#deviceDetailNav:device_overview ”,则您的UID为“ / zport / dmd / Devices / Server” / Linux / devices / xxxx“

you can also find the UUID by inspecting the page source and searching for "uuid" 您还可以通过检查页面源并搜索“ uuid”来找到UUID

The fun and more automatable way, is to use zendmd to look it up. 有趣且更自动化的方式是使用zendmd进行查找。

see the documentation here: support.zenoss.com: zendmd intro 请参阅此处的文档: support.zenoss.com:zendmd简介

  1. attach to your zope container, and su to the zenoss user. 附加到您的zope容器,然后su到zenoss用户。
  2. run zendmd 运行zendmd
  3. Find the device using its name: 使用设备名称查找设备:

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

  4. get the details you need from your dmd device: 从dmd设备获取所需的详细信息:

    • UUID: UUID:

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

    • ID: ID:

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

The best way, is probably to use the JSON API. 最好的方法可能是使用JSON API。

there is a json api guide , and full API documentation json api指南完整的API文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM