itemprototype.get

Description

说明

integer/array itemprototype.get(object **parameters**)

The method allows to retrieve item prototypes according to the given parameters. 此方法可以根据提供的参数获取item prototypes。

Parameters

(object) Parameters defining the desired output. (object) 参数定义期望输出

The method supports the following parameters. 此方法提供以下参数。

ParameterTypeDescription
discoveryidsstring/arrayReturn only item prototypes that belong to the given LLD rules. 只返回属于给定LLD规则的item prototypes。
graphidsstring/arrayReturn only item prototypes that are used in the given graph prototypes.只返回在给定图标原型中使用的item prototypes。
hostidsstring/arrayReturn only item prototypes that belong to the given hosts. 只返回属于给定host的item prototypes。
inheritedbooleanIf set to true return only item prototypes inherited from a template.如果设为“true”,返回继承自某个template的 item prototypes。
itemidsstring/arrayReturn only item prototypes with the given IDs. 返回给定IDS的item prototypes。
monitoredbooleanIf set to true return only enabled item prototypes that belong to monitored hosts.如果设为“true”,只返回已启动的属于已监控主机的item prototypes。
templatedbooleanIf set to true return only item prototypes that belong to templates.如果设为“true”,只发挥属于给定模板的item prototypes。
templateidsstring/arrayReturn only item prototypes that belong to the given templates. 只返回属于给定模板的item prototypes。
triggeridsstring/arrayReturn only item prototypes that are used in the given trigger prototypes.只返回使用在给定trigger prototypes的item prototypes。
selectApplicationsqueryReturn applications that the item prototype belongs to in the applications property.在applications属性中返回item prototype所属的applications。
selectApplicationPrototypesqueryReturn application prototypes linked to item prototype in applicationPrototypes property. 只返回被连接到applicationPrototypes属性中的item prototype的application prototypes。
selectDiscoveryRulequeryReturn the low-level discovery rule that the graph prototype belongs to in the discoveryRule property.在discoveryRule 属性中返回图表原型所属的低级发现规则。
selectGraphsqueryReturn graph prototypes that the item prototype is used in in the graphs property. 在graphs属性中返回被item prototype使用的graph prototypes。

Supports count. 支持count
selectHostsqueryReturns the host that the item prototype belongs to as an array in the hosts property.在hosts属性中以数组的形式返回item prototype所属的host。
selectTriggersqueryReturn trigger prototypes that the item prototype is used in in the triggers property. 在triggers属性中返回item prototype被使用的trigger prototypes。

Supports count. 支持count
selectPreprocessingqueryReturn item preprocessing options in preprocessing property.在preprocessing属性中返回项item preprocessing选项。

It has the following properties: 它有如下属性
type - (string) The preprocessing option types:preprocessing 选项类型:
1 - Custom multiplier;
2 - Right trim;
3 - Left trim;
4 - Trim;
5 - Regular expression matching;
6 - Boolean to decimal;
7 - Octal to decimal;
8 - Hexadecimal to decimal;
9 - Simple change;
10 - Change per second.

params - (string) Additional parameters used by preprocessing option. Multiple parameters are separated by LF (\n)character.
filterobjectReturn only those results that exactly match the given filter.只返回精确匹配筛选条件的结果。

Accepts an array, where the keys are property names, and the values are either a single value or an array of values to match against. 接受一个数组,数组键为属性名称,值为单个值或者数组。

Supports additional filters: 支持可选筛选条件:
host - technical name of the host that the item prototype belongs to. host - item prototype 所属的主机的技术名称。
limitSelectsintegerLimits the number of records returned by subselects. 限制子选择返回的记录数。

Applies to the following subselects:应用于如下子选择:
selectGraphs - results will be sorted by name;
selectTriggers - results will be sorted by description.
sortfieldstring/arraySort the result by the given properties. 根据给定的属性排序

Possible values are:可能的值有: itemid, name, key_, delay, type and status.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary. 这些参数对于所有在reference commentary详细描述的“get”方法都是通用的。
editableboolean
excludeSearchboolean
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

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 item prototypes from an LLD rule

获取 item prototypes

Retrieve all item prototypes from an LLD rule. 从LLD规则中获取所有item prototypes

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "itemprototype.get",
  4. "params": {
  5. "output": "extend",
  6. "discoveryids": "27426"
  7. },
  8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  9. "id": 1
  10. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "itemid": "23077",
  6. "type": "0",
  7. "snmp_community": "",
  8. "snmp_oid": "",
  9. "hostid": "10079",
  10. "name": "Incoming network traffic on $1",
  11. "key_": "net.if.in[en0]",
  12. "delay": "1m",
  13. "history": "1w",
  14. "trends": "365d",
  15. "status": "0",
  16. "value_type": "3",
  17. "trapper_hosts": "",
  18. "units": "bps",
  19. "snmpv3_securityname": "",
  20. "snmpv3_securitylevel": "0",
  21. "snmpv3_authpassphrase": "",
  22. "snmpv3_privpassphrase": "",
  23. "formula": "",
  24. "error": "",
  25. "lastlogsize": "0",
  26. "logtimefmt": "",
  27. "templateid": "0",
  28. "valuemapid": "0",
  29. "params": "",
  30. "ipmi_sensor": "",
  31. "authtype": "0",
  32. "username": "",
  33. "password": "",
  34. "publickey": "",
  35. "privatekey": "",
  36. "mtime": "0",
  37. "flags": "0",
  38. "interfaceid": "0",
  39. "port": "",
  40. "description": "",
  41. "inventory_link": "0",
  42. "lifetime": "30d",
  43. "snmpv3_authprotocol": "0",
  44. "snmpv3_privprotocol": "0",
  45. "state": "0",
  46. "snmpv3_contextname": "",
  47. "evaltype": "0",
  48. "jmx_endpoint": "",
  49. "master_itemid": "0",
  50. "timeout": "3s",
  51. "url": "",
  52. "query_fields": [],
  53. "posts": "",
  54. "status_codes": "200",
  55. "follow_redirects": "1",
  56. "post_type": "0",
  57. "http_proxy": "",
  58. "headers": [],
  59. "retrieve_mode": "0",
  60. "request_method": "1",
  61. "output_format": "0",
  62. "ssl_cert_file": "",
  63. "ssl_key_file": "",
  64. "ssl_key_password": "",
  65. "verify_peer": "0",
  66. "verify_host": "0",
  67. "allow_traps": "0",
  68. "lastclock": "0",
  69. "lastns": "0",
  70. "lastvalue": "0",
  71. "prevvalue": "0"
  72. },
  73. {
  74. "itemid": "10010",
  75. "type": "0",
  76. "snmp_community": "",
  77. "snmp_oid": "",
  78. "hostid": "10001",
  79. "name": "Processor load (1 min average per core)",
  80. "key_": "system.cpu.load[percpu,avg1]",
  81. "delay": "1m",
  82. "history": "1w",
  83. "trends": "365d",
  84. "status": "0",
  85. "value_type": "0",
  86. "trapper_hosts": "",
  87. "units": "",
  88. "snmpv3_securityname": "",
  89. "snmpv3_securitylevel": "0",
  90. "snmpv3_authpassphrase": "",
  91. "snmpv3_privpassphrase": "",
  92. "formula": "",
  93. "error": "",
  94. "lastlogsize": "0",
  95. "logtimefmt": "",
  96. "templateid": "0",
  97. "valuemapid": "0",
  98. "params": "",
  99. "ipmi_sensor": "",
  100. "authtype": "0",
  101. "username": "",
  102. "password": "",
  103. "publickey": "",
  104. "privatekey": "",
  105. "mtime": "0",
  106. "flags": "0",
  107. "interfaceid": "0",
  108. "port": "",
  109. "description": "The processor load is calculated as system CPU load divided by number of CPU cores.",
  110. "inventory_link": "0",
  111. "lifetime": "0",
  112. "snmpv3_authprotocol": "0",
  113. "snmpv3_privprotocol": "0",
  114. "state": "0",
  115. "snmpv3_contextname": "",
  116. "evaltype": "0",
  117. "jmx_endpoint": "",
  118. "master_itemid": "0",
  119. "timeout": "3s",
  120. "url": "",
  121. "query_fields": [],
  122. "posts": "",
  123. "status_codes": "200",
  124. "follow_redirects": "1",
  125. "post_type": "0",
  126. "http_proxy": "",
  127. "headers": [],
  128. "retrieve_mode": "0",
  129. "request_method": "1",
  130. "output_format": "0",
  131. "ssl_cert_file": "",
  132. "ssl_key_file": "",
  133. "ssl_key_password": "",
  134. "verify_peer": "0",
  135. "verify_host": "0",
  136. "allow_traps": "0",
  137. "lastclock": "0",
  138. "lastns": "0",
  139. "lastvalue": "0",
  140. "prevvalue": "0"
  141. }
  142. ],
  143. "id": 1
  144. }

Finding dependent item

查找依赖的item

Find one Dependent item for item with ID “25545”. 为ID为“25545”的item查找一个赖的 item。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "item.get",
  4. "params": {
  5. "output": "extend",
  6. "filter": {
  7. "type": "18",
  8. "master_itemid": "25545"
  9. },
  10. "limit": "1"
  11. },
  12. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  13. "id": 1
  14. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "itemid": "25547",
  6. "type": "18",
  7. "snmp_community": "",
  8. "snmp_oid": "",
  9. "hostid": "10116",
  10. "name": "Seconds",
  11. "key_": "apache.status.uptime.seconds",
  12. "delay": "0",
  13. "history": "90d",
  14. "trends": "365d",
  15. "status": "0",
  16. "value_type": "3",
  17. "trapper_hosts": "",
  18. "units": "",
  19. "snmpv3_securityname": "",
  20. "snmpv3_securitylevel": "0",
  21. "snmpv3_authpassphrase": "",
  22. "snmpv3_privpassphrase": "",
  23. "formula": "",
  24. "error": "",
  25. "lastlogsize": "0",
  26. "logtimefmt": "",
  27. "templateid": "0",
  28. "valuemapid": "0",
  29. "params": "",
  30. "ipmi_sensor": "",
  31. "authtype": "0",
  32. "username": "",
  33. "password": "",
  34. "publickey": "",
  35. "privatekey": "",
  36. "mtime": "0",
  37. "flags": "0",
  38. "interfaceid": "0",
  39. "port": "",
  40. "description": "",
  41. "inventory_link": "0",
  42. "lifetime": "30d",
  43. "snmpv3_authprotocol": "0",
  44. "snmpv3_privprotocol": "0",
  45. "state": "0",
  46. "snmpv3_contextname": "",
  47. "evaltype": "0",
  48. "master_itemid": "25545",
  49. "jmx_endpoint": "",
  50. "master_itemid": "0",
  51. "timeout": "3s",
  52. "url": "",
  53. "query_fields": [],
  54. "posts": "",
  55. "status_codes": "200",
  56. "follow_redirects": "1",
  57. "post_type": "0",
  58. "http_proxy": "",
  59. "headers": [],
  60. "retrieve_mode": "0",
  61. "request_method": "1",
  62. "output_format": "0",
  63. "ssl_cert_file": "",
  64. "ssl_key_file": "",
  65. "ssl_key_password": "",
  66. "verify_peer": "0",
  67. "verify_host": "0",
  68. "allow_traps": "0",
  69. "lastclock": "0",
  70. "lastns": "0",
  71. "lastvalue": "0",
  72. "prevvalue": "0"
  73. }
  74. ],
  75. "id": 1
  76. }

Find HTTP agent item prototype

查找 HTTP agent item prototype

Find HTTP agent item prototype with request method HEAD for specific host id. 为请求方法头定义的host id查找HTTP agent item prototype。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "itemprototype.get",
  4. "params": {
  5. "hostids": "10254",
  6. "filter": {
  7. "type": "19",
  8. "request_method": "3"
  9. }
  10. },
  11. "id": 17,
  12. "auth": "d678e0b85688ce578ff061bd29a20d3b"
  13. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "itemid": "28257",
  6. "type": "19",
  7. "snmp_community": "",
  8. "snmp_oid": "",
  9. "hostid": "10254",
  10. "name": "discovered",
  11. "key_": "item[{#INAME}]",
  12. "delay": "{#IUPDATE}",
  13. "history": "90d",
  14. "trends": "30d",
  15. "status": "0",
  16. "value_type": "3",
  17. "trapper_hosts": "",
  18. "units": "",
  19. "snmpv3_securityname": "",
  20. "snmpv3_securitylevel": "0",
  21. "snmpv3_authpassphrase": "",
  22. "snmpv3_privpassphrase": "",
  23. "formula": "",
  24. "error": "",
  25. "lastlogsize": "0",
  26. "logtimefmt": "",
  27. "templateid": "28255",
  28. "valuemapid": "0",
  29. "params": "",
  30. "ipmi_sensor": "",
  31. "authtype": "0",
  32. "username": "",
  33. "password": "",
  34. "publickey": "",
  35. "privatekey": "",
  36. "mtime": "0",
  37. "flags": "2",
  38. "interfaceid": "2",
  39. "port": "",
  40. "description": "",
  41. "inventory_link": "0",
  42. "lifetime": "30d",
  43. "snmpv3_authprotocol": "0",
  44. "snmpv3_privprotocol": "0",
  45. "state": "0",
  46. "snmpv3_contextname": "",
  47. "evaltype": "0",
  48. "jmx_endpoint": "",
  49. "master_itemid": "0",
  50. "timeout": "3s",
  51. "url": "{#IURL}",
  52. "query_fields": [],
  53. "posts": "",
  54. "status_codes": "",
  55. "follow_redirects": "0",
  56. "post_type": "0",
  57. "http_proxy": "",
  58. "headers": [],
  59. "retrieve_mode": "0",
  60. "request_method": "3",
  61. "output_format": "0",
  62. "ssl_cert_file": "",
  63. "ssl_key_file": "",
  64. "ssl_key_password": "",
  65. "verify_peer": "0",
  66. "verify_host": "0",
  67. "allow_traps": "0"
  68. }
  69. ],
  70. "id": 17
  71. }

See also

参考其他

Source

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