itemprototype.get

Description

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

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

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

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. "parameters": []
  63. },
  64. {
  65. "itemid": "10010",
  66. "type": "0",
  67. "snmp_oid": "",
  68. "hostid": "10001",
  69. "name": "Processor load (1 min average per core)",
  70. "key_": "system.cpu.load[percpu,avg1]",
  71. "delay": "1m",
  72. "history": "1w",
  73. "trends": "365d",
  74. "status": "0",
  75. "value_type": "0",
  76. "trapper_hosts": "",
  77. "units": "",
  78. "formula": "",
  79. "error": "",
  80. "logtimefmt": "",
  81. "templateid": "0",
  82. "valuemapid": "0",
  83. "params": "",
  84. "ipmi_sensor": "",
  85. "authtype": "0",
  86. "username": "",
  87. "password": "",
  88. "publickey": "",
  89. "privatekey": "",
  90. "flags": "0",
  91. "interfaceid": "0",
  92. "description": "The processor load is calculated as system CPU load divided by number of CPU cores.",
  93. "inventory_link": "0",
  94. "lifetime": "0",
  95. "state": "0",
  96. "evaltype": "0",
  97. "jmx_endpoint": "",
  98. "master_itemid": "0",
  99. "timeout": "3s",
  100. "url": "",
  101. "query_fields": [],
  102. "posts": "",
  103. "status_codes": "200",
  104. "follow_redirects": "1",
  105. "post_type": "0",
  106. "http_proxy": "",
  107. "headers": [],
  108. "retrieve_mode": "0",
  109. "request_method": "0",
  110. "output_format": "0",
  111. "ssl_cert_file": "",
  112. "ssl_key_file": "",
  113. "ssl_key_password": "",
  114. "verify_peer": "0",
  115. "verify_host": "0",
  116. "allow_traps": "0",
  117. "lastclock": "0",
  118. "lastns": "0",
  119. "lastvalue": "0",
  120. "prevvalue": "0",
  121. "discover": "0",
  122. "parameters": []
  123. }
  124. ],
  125. "id": 1
  126. }

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. "parameters": []
  64. }
  65. ],
  66. "id": 1
  67. }

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. "parameters": []
  59. }
  60. ],
  61. "id": 17
  62. }

See also

Source

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