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只返回具有给定模板ID的模板.
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只返回具有图形的模板.
with_httptests flag Return only templates that have web scenarios只返回具有Web场景的模板.
selectGroups query Return the host groups that the template belongs to in the groups property在groups属性中返回模板所属的主机组.
selectHosts query Return the hosts that are linked to the template in the hosts property在hosts属性中返回链接到模板的主机. Supports count.
selectTemplates query Return the child templates in the templates property返回templates属性中的子模板. Supports count.
selectParentTemplates query Return the parent templates in the parentTemplates property返回parentTemplates属性中的父模板. Supports count.
selectHttpTestsqueryReturn the web scenarios from the template in the httpSteps property从httpSteps属性中的模板返回Web场景. Supports count.
selectItems query Return items from the template in the items property在items属性中返回模板中的监控项. Supports count.
selectDiscoveries query Return low-level discoveries from the template in the discoveries property从discoveries属性中的模板返回低水平自动发现. Supports count.
selectTriggers query

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请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "template.get",
  4. "params": {
  5. "output": "extend",
  6. "filter": {
  7. "host": [
  8. "Template OS Linux",
  9. "Template OS Windows"
  10. ]
  11. }
  12. },
  13. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  14. "id": 1
  15. }

Response响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "proxy_hostid": "0",
  6. "host": "Template OS Linux",
  7. "status": "3",
  8. "disable_until": "0",
  9. "error": "",
  10. "available": "0",
  11. "errors_from": "0",
  12. "lastaccess": "0",
  13. "ipmi_authtype": "0",
  14. "ipmi_privilege": "2",
  15. "ipmi_username": "",
  16. "ipmi_password": "",
  17. "ipmi_disable_until": "0",
  18. "ipmi_available": "0",
  19. "snmp_disable_until": "0",
  20. "snmp_available": "0",
  21. "maintenanceid": "0",
  22. "maintenance_status": "0",
  23. "maintenance_type": "0",
  24. "maintenance_from": "0",
  25. "ipmi_errors_from": "0",
  26. "snmp_errors_from": "0",
  27. "ipmi_error": "",
  28. "snmp_error": "",
  29. "jmx_disable_until": "0",
  30. "jmx_available": "0",
  31. "jmx_errors_from": "0",
  32. "jmx_error": "",
  33. "name": "Template OS Linux",
  34. "flags": "0",
  35. "templateid": "10001",
  36. "description": "",
  37. "tls_connect": "1",
  38. "tls_accept": "1",
  39. "tls_issuer": "",
  40. "tls_subject": "",
  41. "tls_psk_identity": "",
  42. "tls_psk": ""
  43. },
  44. {
  45. "proxy_hostid": "0",
  46. "host": "Template OS Windows",
  47. "status": "3",
  48. "disable_until": "0",
  49. "error": "",
  50. "available": "0",
  51. "errors_from": "0",
  52. "lastaccess": "0",
  53. "ipmi_authtype": "0",
  54. "ipmi_privilege": "2",
  55. "ipmi_username": "",
  56. "ipmi_password": "",
  57. "ipmi_disable_until": "0",
  58. "ipmi_available": "0",
  59. "snmp_disable_until": "0",
  60. "snmp_available": "0",
  61. "maintenanceid": "0",
  62. "maintenance_status": "0",
  63. "maintenance_type": "0",
  64. "maintenance_from": "0",
  65. "ipmi_errors_from": "0",
  66. "snmp_errors_from": "0",
  67. "ipmi_error": "",
  68. "snmp_error": "",
  69. "jmx_disable_until": "0",
  70. "jmx_available": "0",
  71. "jmx_errors_from": "0",
  72. "jmx_error": "",
  73. "name": "Template OS Windows",
  74. "flags": "0",
  75. "templateid": "10081",
  76. "description": "",
  77. "tls_connect": "1",
  78. "tls_accept": "1",
  79. "tls_issuer": "",
  80. "tls_subject": "",
  81. "tls_psk_identity": "",
  82. "tls_psk": ""
  83. }
  84. ],
  85. "id": 1
  86. }

See also参考

Source来源

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