action.get

Description

integer/array action.get(object parameters)

The method allows to retrieve actions 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
actionidsstring/arrayReturn only actions with the given IDs.
groupidsstring/arrayReturn only actions that use the given host groups in action conditions.
hostidsstring/arrayReturn only actions that use the given hosts in action conditions.
triggeridsstring/arrayReturn only actions that use the given triggers in action conditions.
mediatypeidsstring/arrayReturn only actions that use the given media types to send messages.
usrgrpidsstring/arrayReturn only actions that are configured to send messages to the given user groups.
useridsstring/arrayReturn only actions that are configured to send messages to the given users.
scriptidsstring/arrayReturn only actions that are configured to run the given scripts.
selectFilterqueryReturn a filter property with the action condition filter.
selectOperationsqueryReturn an operations property with action operations.
selectRecoveryOperationsqueryReturn a recovery_operations property with action recovery operations.
selectUpdateOperationsqueryReturn an update_operations property with action update operations.
sortfieldstring/arraySort the result by the given properties.

Possible values are: actionid, name and status.
countOutputbooleanThese parameters being common for all get methods are described in the reference commentary.
editableboolean
excludeSearchboolean
filterobject
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 actions

Retrieve all configured trigger actions together with action conditions and operations.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "action.get",
  4. "params": {
  5. "output": "extend",
  6. "selectOperations": "extend",
  7. "selectRecoveryOperations": "extend",
  8. "selectUpdateOperations": "extend",
  9. "selectFilter": "extend",
  10. "filter": {
  11. "eventsource": 0
  12. }
  13. },
  14. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  15. "id": 1
  16. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "actionid": "3",
  6. "name": "Report problems to Zabbix administrators",
  7. "eventsource": "0",
  8. "status": "1",
  9. "esc_period": "1h",
  10. "pause_suppressed": "1",
  11. "filter": {
  12. "evaltype": "0",
  13. "formula": "",
  14. "conditions": [],
  15. "eval_formula": ""
  16. },
  17. "operations": [
  18. {
  19. "operationid": "3",
  20. "actionid": "3",
  21. "operationtype": "0",
  22. "esc_period": "0",
  23. "esc_step_from": "1",
  24. "esc_step_to": "1",
  25. "evaltype": "0",
  26. "opconditions": [],
  27. "opmessage": [
  28. {
  29. "default_msg": "1",
  30. "subject": "",
  31. "message": "",
  32. "mediatypeid" => "0"
  33. }
  34. ],
  35. "opmessage_grp": [
  36. {
  37. "usrgrpid": "7"
  38. }
  39. ]
  40. }
  41. ],
  42. "recovery_operations": [
  43. {
  44. "operationid": "7",
  45. "actionid": "3",
  46. "operationtype": "11",
  47. "evaltype": "0",
  48. "opconditions": [],
  49. "opmessage": {
  50. "default_msg": "0",
  51. "subject": "{TRIGGER.STATUS}: {TRIGGER.NAME}",
  52. "message": "Trigger: {TRIGGER.NAME}\r\nTrigger status: {TRIGGER.STATUS}\r\nTrigger severity: {TRIGGER.SEVERITY}\r\nTrigger URL: {TRIGGER.URL}\r\n\r\nItem values:\r\n\r\n1. {ITEM.NAME1} ({HOST.NAME1}:{ITEM.KEY1}): {ITEM.VALUE1}\r\n2. {ITEM.NAME2} ({HOST.NAME2}:{ITEM.KEY2}): {ITEM.VALUE2}\r\n3. {ITEM.NAME3} ({HOST.NAME3}:{ITEM.KEY3}): {ITEM.VALUE3}\r\n\r\nOriginal event ID: {EVENT.ID}",
  53. "mediatypeid": "0"
  54. }
  55. }
  56. ],
  57. "update_operations": [
  58. {
  59. "operationid": "31",
  60. "operationtype": "12",
  61. "evaltype": "0",
  62. "opmessage": {
  63. "default_msg": "1",
  64. "subject": "",
  65. "message": "",
  66. "mediatypeid": "0"
  67. }
  68. },
  69. {
  70. "operationid": "32",
  71. "operationtype": "0",
  72. "evaltype": "0",
  73. "opmessage": {
  74. "default_msg": "0",
  75. "subject": "Updated: {TRIGGER.NAME}",
  76. "message": "{USER.FULLNAME} updated problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME} with the following message:\r\n{EVENT.UPDATE.MESSAGE}\r\n\r\nCurrent problem status is {EVENT.STATUS}",
  77. "mediatypeid": "1"
  78. },
  79. "opmessage_grp": [
  80. {
  81. "usrgrpid": "7"
  82. }
  83. ],
  84. "opmessage_usr": []
  85. },
  86. {
  87. "operationid": "33",
  88. "operationtype": "1",
  89. "evaltype": "0",
  90. "opcommand": {
  91. "scriptid": "3"
  92. },
  93. "opcommand_hst": [
  94. {
  95. "hostid": "10084"
  96. }
  97. ],
  98. "opcommand_grp": []
  99. }
  100. ]
  101. }
  102. ],
  103. "id": 1
  104. }

Retrieve discovery actions

Retrieve all configured discovery actions together with action conditions and operations. The filter uses the “and” evaluation type, so the formula property is empty and eval_formula is generated automatically.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "action.get",
  4. "params": {
  5. "output": "extend",
  6. "selectOperations": "extend"
  7. "selectFilter": "extend",
  8. "filter": {
  9. "eventsource": 1
  10. }
  11. },
  12. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  13. "id": 1
  14. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "actionid": "2",
  6. "name": "Auto discovery. Linux servers.",
  7. "eventsource": "1",
  8. "status": "1",
  9. "esc_period": "0s",
  10. "pause_suppressed": "1",
  11. "filter": {
  12. "evaltype": "0",
  13. "formula": "",
  14. "conditions": [
  15. {
  16. "conditiontype": "10",
  17. "operator": "0",
  18. "value": "0",
  19. "value2": "",
  20. "formulaid": "B"
  21. },
  22. {
  23. "conditiontype": "8",
  24. "operator": "0",
  25. "value": "9",
  26. "value2": "",
  27. "formulaid": "C"
  28. },
  29. {
  30. "conditiontype": "12",
  31. "operator": "2",
  32. "value": "Linux",
  33. "value2": "",
  34. "formulaid": "A"
  35. }
  36. ],
  37. "eval_formula": "A and B and C"
  38. },
  39. "operations": [
  40. {
  41. "operationid": "1",
  42. "actionid": "2",
  43. "operationtype": "6",
  44. "esc_period": "0s",
  45. "esc_step_from": "1",
  46. "esc_step_to": "1",
  47. "evaltype": "0",
  48. "opconditions": [],
  49. "optemplate": [
  50. {
  51. "templateid": "10001"
  52. }
  53. ]
  54. },
  55. {
  56. "operationid": "2",
  57. "actionid": "2",
  58. "operationtype": "4",
  59. "esc_period": "0s",
  60. "esc_step_from": "1",
  61. "esc_step_to": "1",
  62. "evaltype": "0",
  63. "opconditions": [],
  64. "opgroup": [
  65. {
  66. "groupid": "2"
  67. }
  68. ]
  69. }
  70. ]
  71. }
  72. ],
  73. "id": 1
  74. }

See also

Source

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