hostprototype.get

Description 说明

integer/array hostprototype.get(object parameters)

The method allows to retrieve host prototypes according to the given parameters.该方法允许根据给定的参数检索主机原型。

Parameters 参数

(object) Parameters defining the desired output.定义所需输出的参数。

The method supports the following parameters.该方法支持以下参数。

参数 类型 描述
hostids string/array Return only host prototypes with the given IDs.只返回具有给定ID的主机原型
discoveryids string/array Return only host prototype that belong to the given LLD rules.仅返回属于给定LLD规则的主机原型。
inherited boolean If set to true return only items inherited from a template.如果设置为“true”,只返回从模板继承的项目。
selectDiscoveryRule query Return the LLD rule that the host prototype belongs to in the discoveryRule property.在“discoveryRule”属性中返回主机原型所属的LLD规则。
selectGroupLinks query Return the group links of the host prototype in the groupLinks property.在“groupLinks”属性中返回主机原型的组链接。
selectGroupPrototypes query Return the group prototypes of the host prototype in the groupPrototypes property.返回“groupPrototypes”属性中的主机原型的组原型。
selectInventory query Return the host prototype inventory in the inventory property.在“库存”属性中返回主机原型库存。
selectParentHost query Return the host that the host prototype belongs to in the parentHost property. 在“parentHost”属性中返回主机原型所属的主机。
selectTemplates query Return the templates linked to the host prototype in the templates property. 返回在“模板”属性中链接到主机原型的模板。
sortfield string/array Sort the result by the given properties. 按照给定的属性对结果进行排序。Possible values are: hostid, host, name and status. 可能的值是:'hostid,'hostnamestatus
countOutput flagThese parameters being common for all get methods are described in detail on the Generic Zabbix API information page.通用Zabbix API信息页面详细描述了所有“get”方法的这些参数。
editable boolean
excludeSearch flag
filter object
limit integer
output query
preservekeys flag
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch flag

Return values 返回值

(integer/array) Returns either:返回:

  • an array of objects;一组对象;

  • the count of retrieved objects, if the countOutput parameter has been used.如果已经使用“countOutput”参数,则检索到的对象的计数。

Examples 示例

Retrieving host prototypes from an LLD rule从LLD规则检索主机原型

Retrieve all host prototypes and their group links and group prototypes from an LLD rule.从LLD规则中检索所有主机原型及其组链接和组原型。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hostprototype.get",
  4. "params": {
  5. "output": "extend",
  6. "selectGroupLinks": "extend",
  7. "selectGroupPrototypes": "extend",
  8. "discoveryids": "23554"
  9. },
  10. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  11. "id": 1
  12. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "hostid": "10092",
  6. "host": "{#HV.UUID}",
  7. "status": "0",
  8. "name": "{#HV.NAME}",
  9. "templateid": "0",
  10. "tls_connect": "1",
  11. "tls_accept": "1",
  12. "tls_issuer": "",
  13. "tls_subject": "",
  14. "tls_psk_identity": "",
  15. "tls_psk": "",
  16. "groupLinks": [
  17. {
  18. "group_prototypeid": "4",
  19. "hostid": "10092",
  20. "groupid": "7",
  21. "templateid": "0"
  22. }
  23. ],
  24. "groupPrototypes": [
  25. {
  26. "group_prototypeid": "7",
  27. "hostid": "10092",
  28. "name": "{#CLUSTER.NAME}",
  29. "templateid": "0"
  30. }
  31. ]
  32. }
  33. ],
  34. "id": 1
  35. }

See also 参见

Source 来源

CHostPrototype::get() in frontends/php/include/classes/api/services/CHostPrototype.php.