triggerprototype.get

Description

integer/array triggerprototype.get(object parameters)

The method allows to retrieve trigger 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
activeflagReturn only enabled trigger prototypes that belong to monitored hosts.
discoveryidsstring/arrayReturn only trigger prototypes that belong to the given LLD rules.
functionsstring/arrayReturn only triggers that use the given functions.

Refer to the supported trigger functions page for a list of supported functions.
groupstringReturn only trigger prototypes that belong to hosts from the host groups with the given name.
groupidsstring/arrayReturn only trigger prototypes that belong to hosts from the given host groups.
hoststringReturn only trigger prototypes that belong to hosts with the given name.
hostidsstring/arrayReturn only trigger prototypes that belong to the given hosts.
inheritedbooleanIf set to true return only trigger prototypes inherited from a template.
maintenancebooleanIf set to true return only enabled trigger prototypes that belong to hosts in maintenance.
min_severityintegerReturn only trigger prototypes with severity greater or equal than the given severity.
monitoredflagReturn only enabled trigger prototypes that belong to monitored hosts and contain only enabled items.
templatedbooleanIf set to true return only trigger prototypes that belong to templates.
templateidsstring/arrayReturn only trigger prototypes that belong to the given templates.
triggeridsstring/arrayReturn only trigger prototypes with the given IDs.
expandExpressionflagExpand functions and macros in the trigger expression.
selectDependenciesqueryReturn trigger prototypes and triggers that the trigger prototype depends on in the dependencies property.
selectDiscoveryRulequeryReturn the LLD rule that the trigger prototype belongs to.
selectFunctionsqueryReturn functions used in the trigger prototype in the functions property.

The function objects represent the functions used in the trigger expression and has the following properties:
functionid - (string) ID of the function;
itemid - (string) ID of the item used in the function;
function - (string) name of the function;
parameter - (string) parameter passed to the function. Query parameter is replaced by $ symbol in returned string.
selectGroupsqueryReturn the host groups that the trigger prototype belongs to in the groups property.
selectHostsqueryReturn the hosts that the trigger prototype belongs to in the hosts property.
selectItemsqueryReturn items and item prototypes used the trigger prototype in the items property.
selectTagsqueryReturn the trigger prototype tags in tags property.
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 trigger prototype belongs to;
hostid - ID of the host that the trigger prototype belongs to.
limitSelectsintegerLimits the number of records returned by subselects.

Applies to the following subselects:
selectHosts - results will be sorted by host.
sortfieldstring/arraySort the result by the given properties.

Possible values are: triggerid, description, status and priority.
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

Retrieve trigger prototypes from an LLD rule

Retrieve all trigger prototypes and their functions from an LLD rule.

Request:

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

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "triggerid": "13272",
  6. "expression": "{12598}<20",
  7. "description": "Free inodes is less than 20% on volume {#FSNAME}",
  8. "url": "",
  9. "status": "0",
  10. "priority": "2",
  11. "comments": "",
  12. "templateid": "0",
  13. "type": "0",
  14. "flags": "2",
  15. "recovery_mode": "0",
  16. "recovery_expression": "",
  17. "correlation_mode": "0",
  18. "correlation_tag": "",
  19. "manual_close": "0",
  20. "opdata": "",
  21. "discover": "0",
  22. "functions": [
  23. {
  24. "functionid": "12598",
  25. "itemid": "22454",
  26. "triggerid": "13272",
  27. "parameter": "$",
  28. "function": "last"
  29. }
  30. ]
  31. },
  32. {
  33. "triggerid": "13266",
  34. "expression": "{13500}<20",
  35. "description": "Free disk space is less than 20% on volume {#FSNAME}",
  36. "url": "",
  37. "status": "0",
  38. "priority": "2",
  39. "comments": "",
  40. "templateid": "0",
  41. "type": "0",
  42. "flags": "2",
  43. "recovery_mode": "0",
  44. "recovery_expression": "",
  45. "correlation_mode": "0",
  46. "correlation_tag": "",
  47. "manual_close": "0",
  48. "opdata": "",
  49. "discover": "0",
  50. "functions": [
  51. {
  52. "functionid": "13500",
  53. "itemid": "22686",
  54. "triggerid": "13266",
  55. "parameter": "$",
  56. "function": "last"
  57. }
  58. ]
  59. }
  60. ],
  61. "id": 1
  62. }

Retrieving a specific trigger prototype with tags

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "triggerprototype.get",
  4. "params": {
  5. "output": [
  6. "triggerid",
  7. "description"
  8. ]
  9. "selectTags": "extend",
  10. "triggerids": [
  11. "17373"
  12. ]
  13. },
  14. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  15. "id": 1
  16. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "triggerid": "17373",
  6. "description": "Free disk space is less than 20% on volume {#FSNAME}",
  7. "tags": [
  8. {
  9. "tag": "volume",
  10. "value": "{#FSNAME}"
  11. },
  12. {
  13. "tag": "type",
  14. "value": "{#FSTYPE}"
  15. }
  16. ]
  17. }
  18. ],
  19. "id": 1
  20. }

See also

Source

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