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 recoveryOperations property with action recovery operations.
selectAcknowledgeOperationsqueryReturn an acknowledgeOperations 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. "selectAcknowledgeOperations": "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. "acknowledgeOperations": [
  18. {
  19. "operationid": "31",
  20. "operationtype": "12",
  21. "evaltype": "0",
  22. "opmessage": {
  23. "default_msg": "1",
  24. "subject": "",
  25. "message": "",
  26. "mediatypeid": "0"
  27. }
  28. },
  29. {
  30. "operationid": "32",
  31. "operationtype": "0",
  32. "evaltype": "0",
  33. "opmessage": {
  34. "default_msg": "0",
  35. "subject": "Updated: {TRIGGER.NAME}",
  36. "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}",
  37. "mediatypeid": "1"
  38. },
  39. "opmessage_grp": [
  40. {
  41. "usrgrpid": "7"
  42. }
  43. ],
  44. "opmessage_usr": []
  45. },
  46. {
  47. "operationid": "33",
  48. "operationtype": "1",
  49. "evaltype": "0",
  50. "opcommand": {
  51. "type": "0",
  52. "scriptid": "0",
  53. "execute_on": "0",
  54. "port": "",
  55. "authtype": "0",
  56. "username": "",
  57. "password": "",
  58. "publickey": "",
  59. "privatekey": "",
  60. "command": "notify.sh"
  61. },
  62. "opcommand_hst": [
  63. {
  64. "hostid": "0"
  65. }
  66. ],
  67. "opcommand_grp": []
  68. }
  69. ],
  70. "operations": [
  71. {
  72. "operationid": "3",
  73. "actionid": "3",
  74. "operationtype": "0",
  75. "esc_period": "0",
  76. "esc_step_from": "1",
  77. "esc_step_to": "1",
  78. "evaltype": "0",
  79. "opconditions": [],
  80. "opmessage": [
  81. {
  82. "default_msg": "1",
  83. "subject": "",
  84. "message": "",
  85. "mediatypeid" => "0"
  86. }
  87. ],
  88. "opmessage_grp": [
  89. {
  90. "usrgrpid": "7"
  91. }
  92. ]
  93. }
  94. ],
  95. "recoveryOperations": [
  96. {
  97. "operationid": "7",
  98. "actionid": "3",
  99. "operationtype": "11",
  100. "evaltype": "0",
  101. "opconditions": [],
  102. "opmessage": {
  103. "default_msg": "0",
  104. "subject": "{TRIGGER.STATUS}: {TRIGGER.NAME}",
  105. "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}",
  106. "mediatypeid": "0"
  107. }
  108. }
  109. ]
  110. }
  111. ],
  112. "id": 1
  113. }

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.