itemprototype.get

Description

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

The method allows to retrieve item prototypes according to the given parameters.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
discoveryidsstring/arrayReturn only item prototypes that belong to the given LLD rules.
graphidsstring/arrayReturn only item prototypes that are used in the given graph prototypes.
hostidsstring/arrayReturn only item prototypes that belong to the given hosts.
inheritedbooleanIf set to true return only item prototypes inherited from a template.
itemidsstring/arrayReturn only item prototypes with the given IDs.
monitoredbooleanIf set to true return only enabled item prototypes that belong to monitored hosts.
templatedbooleanIf set to true return only item prototypes that belong to templates.
templateidsstring/arrayReturn only item prototypes that belong to the given templates.
triggeridsstring/arrayReturn only item prototypes that are used in the given trigger prototypes.
selectApplicationsqueryReturn an applications property with applications that the item prototype belongs to.
selectApplicationPrototypesqueryReturn applicationPrototypes property with application prototypes linked to item prototype.
selectDiscoveryRulequeryReturn a discoveryRule property with the low-level discovery rule that the item prototype belongs to.
selectGraphsqueryReturn a graphprototype property with graph prototypes that the item prototype is used in.

Supports count.
selectHostsqueryReturn a hosts property with an array of hosts that the item prototype belongs to.
selectTriggersqueryReturn a triggers property with trigger prototypes that the item prototype is used in.

Supports count.
selectPreprocessingqueryReturn a preprocessing property with item preprocessing options.

It has the following properties:
type - (string) The preprocessing option type:
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;
11 - XML XPath;
12 - JSONPath;
13 - In range;
14 - Matches regular expression;
15 - Does not match regular expression;
16 - Check for error in JSON;
17 - Check for error in XML;
18 - Check for error using regular expression;
19 - Discard unchanged;
20 - Discard unchanged with heartbeat;
21 - JavaScript;
22 - Prometheus pattern;
23 - Prometheus to JSON;
24 - CSV to JSON;
25 - Replace.

params - (string) Additional parameters used by preprocessing option. Multiple parameters are separated by LF (\n)character.
error_handler - (string) Action type used in case of preprocessing step failure:
0 - Error message is set by Zabbix server;
1 - Discard value;
2 - Set custom value;
3 - Set custom error message.

error_handler_params - (string) Error handler parameters.
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.
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.
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.

Examples

Retrieving item prototypes from an LLD rule

Retrieve all item prototypes from an LLD rule.

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

Finding dependent item

Find one Dependent item for item with ID “25545”.

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_oid": "",
  8. "hostid": "10116",
  9. "name": "Seconds",
  10. "key_": "apache.status.uptime.seconds",
  11. "delay": "0",
  12. "history": "90d",
  13. "trends": "365d",
  14. "status": "0",
  15. "value_type": "3",
  16. "trapper_hosts": "",
  17. "units": "",
  18. "formula": "",
  19. "error": "",
  20. "logtimefmt": "",
  21. "templateid": "0",
  22. "valuemapid": "0",
  23. "params": "",
  24. "ipmi_sensor": "",
  25. "authtype": "0",
  26. "username": "",
  27. "password": "",
  28. "publickey": "",
  29. "privatekey": "",
  30. "flags": "0",
  31. "interfaceid": "0",
  32. "description": "",
  33. "inventory_link": "0",
  34. "lifetime": "30d",
  35. "state": "0",
  36. "evaltype": "0",
  37. "master_itemid": "25545",
  38. "jmx_endpoint": "",
  39. "master_itemid": "0",
  40. "timeout": "3s",
  41. "url": "",
  42. "query_fields": [],
  43. "posts": "",
  44. "status_codes": "200",
  45. "follow_redirects": "1",
  46. "post_type": "0",
  47. "http_proxy": "",
  48. "headers": [],
  49. "retrieve_mode": "0",
  50. "request_method": "0",
  51. "output_format": "0",
  52. "ssl_cert_file": "",
  53. "ssl_key_file": "",
  54. "ssl_key_password": "",
  55. "verify_peer": "0",
  56. "verify_host": "0",
  57. "allow_traps": "0",
  58. "lastclock": "0",
  59. "lastns": "0",
  60. "lastvalue": "0",
  61. "prevvalue": "0",
  62. "discover": "0"
  63. }
  64. ],
  65. "id": 1
  66. }

Find HTTP agent item prototype

Find HTTP agent item prototype with request method HEAD for specific host id.

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_oid": "",
  8. "hostid": "10254",
  9. "name": "discovered",
  10. "key_": "item[{#INAME}]",
  11. "delay": "{#IUPDATE}",
  12. "history": "90d",
  13. "trends": "30d",
  14. "status": "0",
  15. "value_type": "3",
  16. "trapper_hosts": "",
  17. "units": "",
  18. "formula": "",
  19. "error": "",
  20. "logtimefmt": "",
  21. "templateid": "28255",
  22. "valuemapid": "0",
  23. "params": "",
  24. "ipmi_sensor": "",
  25. "authtype": "0",
  26. "username": "",
  27. "password": "",
  28. "publickey": "",
  29. "privatekey": "",
  30. "flags": "2",
  31. "interfaceid": "2",
  32. "description": "",
  33. "inventory_link": "0",
  34. "lifetime": "30d",
  35. "state": "0",
  36. "evaltype": "0",
  37. "jmx_endpoint": "",
  38. "master_itemid": "0",
  39. "timeout": "3s",
  40. "url": "{#IURL}",
  41. "query_fields": [],
  42. "posts": "",
  43. "status_codes": "",
  44. "follow_redirects": "0",
  45. "post_type": "0",
  46. "http_proxy": "",
  47. "headers": [],
  48. "retrieve_mode": "0",
  49. "request_method": "3",
  50. "output_format": "0",
  51. "ssl_cert_file": "",
  52. "ssl_key_file": "",
  53. "ssl_key_password": "",
  54. "verify_peer": "0",
  55. "verify_host": "0",
  56. "allow_traps": "0",
  57. "discover": "0"
  58. }
  59. ],
  60. "id": 17
  61. }

See also

Source

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