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.
selectDiscoveryRulequeryReturn a discoveryRule property with the low-level discovery rule that the item prototype belongs to.
selectGraphsqueryReturn a graphs 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.
selectTagsqueryReturn the item prototype tags in tags property.
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;
26 - Check for not supported value;
27 - XML to JSON;
28 - SNMP walk value;
29 - SNMP walk to JSON.
params - (string) Additional parameters used by preprocessing option. Multiple parameters are separated by the newline (\n) character.
errorhandler - (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.
selectValueMapqueryReturn a valuemap property with item prototype value map.
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: itemid, name, key, delay, type, 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 for specific LLD rule ID.

Request:

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

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. "logtimefmt": "",
  19. "templateid": "0",
  20. "valuemapid": "0",
  21. "params": "",
  22. "ipmi_sensor": "",
  23. "authtype": "0",
  24. "username": "",
  25. "password": "",
  26. "publickey": "",
  27. "privatekey": "",
  28. "interfaceid": "0",
  29. "description": "",
  30. "evaltype": "0",
  31. "jmx_endpoint": "",
  32. "master_itemid": "0",
  33. "timeout": "3s",
  34. "url": "",
  35. "query_fields": [],
  36. "posts": "",
  37. "status_codes": "200",
  38. "follow_redirects": "1",
  39. "post_type": "0",
  40. "http_proxy": "",
  41. "headers": [],
  42. "retrieve_mode": "0",
  43. "request_method": "0",
  44. "output_format": "0",
  45. "ssl_cert_file": "",
  46. "ssl_key_file": "",
  47. "ssl_key_password": "",
  48. "verify_peer": "0",
  49. "verify_host": "0",
  50. "allow_traps": "0",
  51. "discover": "0",
  52. "uuid": "",
  53. "parameters": []
  54. },
  55. {
  56. "itemid": "10010",
  57. "type": "0",
  58. "snmp_oid": "",
  59. "hostid": "10001",
  60. "name": "Processor load (1 min average per core)",
  61. "key_": "system.cpu.load[percpu,avg1]",
  62. "delay": "1m",
  63. "history": "1w",
  64. "trends": "365d",
  65. "status": "0",
  66. "value_type": "0",
  67. "trapper_hosts": "",
  68. "units": "",
  69. "logtimefmt": "",
  70. "templateid": "0",
  71. "valuemapid": "0",
  72. "params": "",
  73. "ipmi_sensor": "",
  74. "authtype": "0",
  75. "username": "",
  76. "password": "",
  77. "publickey": "",
  78. "privatekey": "",
  79. "interfaceid": "0",
  80. "description": "The processor load is calculated as system CPU load divided by number of CPU cores.",
  81. "evaltype": "0",
  82. "jmx_endpoint": "",
  83. "master_itemid": "0",
  84. "timeout": "3s",
  85. "url": "",
  86. "query_fields": [],
  87. "posts": "",
  88. "status_codes": "200",
  89. "follow_redirects": "1",
  90. "post_type": "0",
  91. "http_proxy": "",
  92. "headers": [],
  93. "retrieve_mode": "0",
  94. "request_method": "0",
  95. "output_format": "0",
  96. "ssl_cert_file": "",
  97. "ssl_key_file": "",
  98. "ssl_key_password": "",
  99. "verify_peer": "0",
  100. "verify_host": "0",
  101. "allow_traps": "0",
  102. "discover": "0",
  103. "uuid": "",
  104. "parameters": []
  105. }
  106. ],
  107. "id": 1
  108. }

Finding dependent item

Find one Dependent item for specific item ID.

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. "id": 1
  13. }

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. "logtimefmt": "",
  19. "templateid": "0",
  20. "valuemapid": "0",
  21. "params": "",
  22. "ipmi_sensor": "",
  23. "authtype": "0",
  24. "username": "",
  25. "password": "",
  26. "publickey": "",
  27. "privatekey": "",
  28. "interfaceid": "0",
  29. "description": "",
  30. "evaltype": "0",
  31. "master_itemid": "25545",
  32. "jmx_endpoint": "",
  33. "timeout": "3s",
  34. "url": "",
  35. "query_fields": [],
  36. "posts": "",
  37. "status_codes": "200",
  38. "follow_redirects": "1",
  39. "post_type": "0",
  40. "http_proxy": "",
  41. "headers": [],
  42. "retrieve_mode": "0",
  43. "request_method": "0",
  44. "output_format": "0",
  45. "ssl_cert_file": "",
  46. "ssl_key_file": "",
  47. "ssl_key_password": "",
  48. "verify_peer": "0",
  49. "verify_host": "0",
  50. "allow_traps": "0",
  51. "discover": "0",
  52. "uuid": "",
  53. "parameters": []
  54. }
  55. ],
  56. "id": 1
  57. }

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": 1
  12. }

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. "logtimefmt": "",
  19. "templateid": "28255",
  20. "valuemapid": "0",
  21. "params": "",
  22. "ipmi_sensor": "",
  23. "authtype": "0",
  24. "username": "",
  25. "password": "",
  26. "publickey": "",
  27. "privatekey": "",
  28. "flags": "2",
  29. "interfaceid": "2",
  30. "description": "",
  31. "evaltype": "0",
  32. "jmx_endpoint": "",
  33. "master_itemid": "0",
  34. "timeout": "3s",
  35. "url": "{#IURL}",
  36. "query_fields": [],
  37. "posts": "",
  38. "status_codes": "",
  39. "follow_redirects": "0",
  40. "post_type": "0",
  41. "http_proxy": "",
  42. "headers": [],
  43. "retrieve_mode": "0",
  44. "request_method": "3",
  45. "output_format": "0",
  46. "ssl_cert_file": "",
  47. "ssl_key_file": "",
  48. "ssl_key_password": "",
  49. "verify_peer": "0",
  50. "verify_host": "0",
  51. "allow_traps": "0",
  52. "discover": "0",
  53. "uuid": "",
  54. "parameters": []
  55. }
  56. ],
  57. "id": 1
  58. }

See also

Source

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