On this page
template.get
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.
The method supports the following parameters.
| Parameter | Type | Description |
|---|---|---|
| templateids | string/array | Return only templates with the given template IDs. |
| groupids | string/array | Return only templates that belong to the given host groups. |
| parentTemplateids | string/array | Return only templates that are children of the given templates. |
| hostids | string/array | Return only templates that are linked to the given hosts. |
| graphids | string/array | Return only templates that contain the given graphs. |
| itemids | string/array | Return only templates that contain the given items. |
| triggerids | string/array | Return only templates that contain the given triggers. |
| with_items | flag | Return only templates that have items. |
| with_triggers | flag | Return only templates that have triggers. |
| with_graphs | flag | Return only templates that have graphs. |
| selectGroups | query | Return the host groups that the template belongs to in the groups property.Does not support shorten or arrays of properties. |
| selectHosts | query | Return the hosts that are linked to the template in the hosts property.Supports count; does not support shorten. |
| selectTemplates | query | Return the child templates in the templates property.Supports count; does not support shorten. |
| selectParentTemplates | query | Return the parent templates in the parentTemplates property.Supports count; does not support shorten. |
| selectItems | query | Return items from the template in the items property.Supports count; does not support shorten. |
| selectDiscoveries | query | Return low-level discoveries from the template in the discoveries property.Supports count; does not support shorten. |
| selectTriggers | query | Return triggers from the template in the triggers property.Supports count; does not support shorten. |
| selectGraphs | query | Return graphs from the template in the graphs property.Supports count; does not support shorten. |
| selectApplications | query | Return applications from the template in the applications property.Supports count; does not support shorten. |
| selectMacros | query | Return the macros from the template in the macros property.Does not support shorten or arrays of properties. |
| selectScreens | query | Return screens from the template in the screens property.Supports count; does not support shorten. |
| limitSelects | integer | Limits the number of records returned by subselects. Applies to the following subselects: selectTemplates - results will be sorted by name;selectHosts - sorted by host;selectParentTemplates - sorted by host;selectItems - sorted by name;selectDiscoveries - sorted by name;selectTriggers - sorted by description;selectGraphs - sorted by name;selectApplications - sorted by name;selectScreens - sorted by name. |
| sortfield | string/array | Sort the result by the given properties. Possible values are: hostid, host, name, status. |
| countOutput | flag | These parameters being common for all get methods are described in detail on the Generic Zabbix API information page. |
| editable | boolean | |
| excludeSearch | flag | |
| filter | object | |
| limit | integer | |
| nodeids | string/array | |
| 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
countOutputparameter has been used.
Examples
Retrieving templates by name
Retrieve all data about two templates named "Template OS Linux" and "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": [
{
"hostid": "10001",
"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",
"templateid": "10001"
},
{
"hostid": "10081",
"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",
"templateid": "10081"
}
],
"id": 1
}
See also
Source
CTemplate::get() in frontends/php/api/classes/CTemplate.php.