Sidebar

2022 Zabbix中国峰会
2022 Zabbix中国峰会

获取

Description 说明

integer/array template.get(object parameters)

The method allows to retrieve templates according to the given parameters. 此方法允许根据指定的参数检索模板。

Parameters 参数

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

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

Parameter 参数 T pe 类型 Des ription 说明
templateids string/array 字符串/数组 Retu n only templates with the given template IDs. 只返回指定模板ID的模板。
groupids string/array 字符串/数组 Retu n only templates that belong to the given host groups. 只返回指定主机组所属的模板。
parentTemplateids string/array 字符串/数组 Retu n only templates that are children of the given templates. 只返回指定子类模板的模板。
hostids string/array 字符串/数组 Retu n only templates that are linked to the given hosts. 只返回被链接到指定主机的模板。
graphids string/array 字符串/数组 Retu n only templates that contain the given graphs. 只返回包含指定图形的模板。
itemids string/array 字符串/数组 Retu n only templates that contain the given items. 只返回包含指定监控项的模板。
triggerids string/array 字符串/数组 Retu n only templates that contain the given triggers. 只返回包含指定触发器的模板。
with_items flag 标记 R turn only templates that have items. 只返回具有监控项的模板。
with_triggers flag 标记 R turn only templates that have triggers. 只返回具有触发器的模板。
with_graphs flag 标记 R turn only templates that have graphs. 只返回具有图形的模板。
with_httptests flag 标记 R turn only templates that have web scenarios. 只返回具有web场景的模板。
selectGroups query 查询 R turn the host groups that the template belongs to in the groups property. 从groups属性中返回所属模板的主机组。
selectHosts query 查询 R turn the hosts that are linked to the template in the hosts property. 从hosts属性中返回被链接模板的主机。

Supports count. 支持count
selectTemplates query 查询 R turn the child templates in the templates property. 从templates属性中返回子类模板。

Supports count. 支持count
selectParentTemplates query 查询 R turn the parent templates in the parentTemplates property. 从parentTemplates属性中返回父类模板。

Supports count. 支持count
selectHttpTests query 查询 R turn the web scenarios from the template in the httpTests property. 从httpTests属性中返回来自模板的web场景。

Supports count. 支持count
selectItems query 查询 R turn items from the template in the items property. 从items属性中返回来自模板的监控项。

Supports count. 支持count
selectDiscoveries query 查询 R turn low-level discoveries from the template in the discoveries property. 从discoveries属性中返回来自模板的低级别发现。

Supports count. 支持count
selectTriggers query 查询 R turn triggers from the template in the triggers property. 从triggers属性中返回来自模板的触发器。

Supports count. 支持count
selectGraphs query 查询 R turn graphs from the template in the graphs property. 从graphs属性中返回来自模板的图表。

Supports count. 支持count
selectApplications query 查询 R turn applications from the template in the applications property. 从applications属性中返回来自模板的应用。

Supports count. 支持count
selectMacros query 查询 R turn the macros from the template in the macros property. 从macros属性中返回来自模板的宏。
selectScreens query 查询 R turn screens from the template in the screens property. 从screens属性中返回来自模板的聚合图形。

Supports count. 支持count
limitSelects integer 整数型 Li its the number of records returned by subselects. 限制子查询返回的记录数。

Applies to the following subselects: 应用于以下子查询:
selectTemplates - results will be sorted by name; 结果将以name排序;
selectHosts - sorted by host; 以host排序;
selectParentTemplates - sorted by host; 以host排序;
selectItems - sorted by name; 以name排序;
selectDiscoveries - sorted by name; 以name排序;
selectTriggers - sorted by description; 以description排序;
selectGraphs - sorted by name; 以name排序;
selectApplications - sorted by name; 以name排序;
selectScreens - sorted by name. 以name排序;
sortfield string/array 字符串/数组 Sort the result by the given properties. 根据给定的属性为结果排序。

Possible values are: hostid, host, name, status. 许可值为:hostid,host,name,status
countOutput boolean 布尔值 Th se parameters being common for all get methods are described in detail in the reference commentary. 这些参数十分普遍,适用所有get方法,详情参见reference commentary
editable boolean 布尔值 ::
excludeSearch boolean 布尔值 ::
filter object 对象 : :
limit integer 整数型 ::
output query 查询 : :
preservekeys boolean 布尔值 ::
search object 对象 : :
searchByAny boolean 布尔值 ::
searchWildcardsEnabled boolean 布尔值 ::
sortorder string/array 字符串/数组 :::
startSearch boolean 布尔值 ::

Return values 返回值

(integer/array) Returns either: (integer/array)返回两者其中任一:

  • an array of objects; 一组对象;
  • the count of retrieved objects, if the countOutput parameter has been used. 如果已经使用了countOutput参数,则检索对象的计数。

Examples 范例

Retrieving templates by name 按名称检索模板

Retrieve all data about two templates named "Template OS Linux" and "Template OS Windows". 检索名称为"Template OS Linux"和"Template OS Windows"这两个模板的所有数据。 Request 请求:

{
           "jsonrpc": "2.0",
           "method": "template.get",
           "params": {
               "output": "extend",
               "filter": {
                   "host": [
                       "Template OS Linux",
                       "Template OS Windows"
                   ]
               }
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response 响应:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "proxy_hostid": "0",
                   "host": "Template OS Linux",
                   "status": "3",
                   "disable_until": "0",
                   "error": "",
                   "available": "0",
                   "errors_from": "0",
                   "lastaccess": "0",
                   "ipmi_authtype": "0",
                   "ipmi_privilege": "2",
                   "ipmi_username": "",
                   "ipmi_password": "",
                   "ipmi_disable_until": "0",
                   "ipmi_available": "0",
                   "snmp_disable_until": "0",
                   "snmp_available": "0",
                   "maintenanceid": "0",
                   "maintenance_status": "0",
                   "maintenance_type": "0",
                   "maintenance_from": "0",
                   "ipmi_errors_from": "0",
                   "snmp_errors_from": "0",
                   "ipmi_error": "",
                   "snmp_error": "",
                   "jmx_disable_until": "0",
                   "jmx_available": "0",
                   "jmx_errors_from": "0",
                   "jmx_error": "",
                   "name": "Template OS Linux",
                   "flags": "0",
                   "templateid": "10001",
                   "description": "",
                   "tls_connect": "1",
                   "tls_accept": "1",
                   "tls_issuer": "",
                   "tls_subject": "",
                   "tls_psk_identity": "",
                   "tls_psk": ""
               },
               {
                   "proxy_hostid": "0",
                   "host": "Template OS Windows",
                   "status": "3",
                   "disable_until": "0",
                   "error": "",
                   "available": "0",
                   "errors_from": "0",
                   "lastaccess": "0",
                   "ipmi_authtype": "0",
                   "ipmi_privilege": "2",
                   "ipmi_username": "",
                   "ipmi_password": "",
                   "ipmi_disable_until": "0",
                   "ipmi_available": "0",
                   "snmp_disable_until": "0",
                   "snmp_available": "0",
                   "maintenanceid": "0",
                   "maintenance_status": "0",
                   "maintenance_type": "0",
                   "maintenance_from": "0",
                   "ipmi_errors_from": "0",
                   "snmp_errors_from": "0",
                   "ipmi_error": "",
                   "snmp_error": "",
                   "jmx_disable_until": "0",
                   "jmx_available": "0",
                   "jmx_errors_from": "0",
                   "jmx_error": "",
                   "name": "Template OS Windows",
                   "flags": "0",
                   "templateid": "10081",
                   "description": "",
                   "tls_connect": "1",
                   "tls_accept": "1",
                   "tls_issuer": "",
                   "tls_subject": "",
                   "tls_psk_identity": "",
                   "tls_psk": ""
               }
           ],
           "id": 1
       }

See also 参考

Source 源码

CTemplate::get() in frontends/php/include/classes/api/services/CTemplate.php. CTemplate::get()方法可在frontends/php/include/classes/api/services/CTemplate.php中参考。

Source

CTemplate::get() in ui/include/classes/api/services/CTemplate.php.