task.get

Description

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

The method allows to retrieve tasks according to the given parameters. Method returns details only about ‘diagnostic information’ tasks.

This method is available since Zabbix version 5.0.5.

For for non-Super Admins users, method returns an insufficient permission message.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
taskidsstring/arrayReturn only tasks with the given IDs.
outputqueryThese parameters being common for all get methods are described in detail in the reference commentary.
preservekeysboolean

Return values

(integer/array) Returns an array of objects.

Examples

Retrieve task by ID

Retrieve all data about task “1”.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "task.get",
  4. "params": {
  5. "output": "extend",
  6. "taskids": "1"
  7. },
  8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  9. "id": 1
  10. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "taskid": "1",
  6. "type": "7",
  7. "status": "3",
  8. "clock": "1601039076",
  9. "ttl": "3600",
  10. "proxy_hostid": null,
  11. "request": {
  12. "alerting": {
  13. "stats": [
  14. "alerts"
  15. ],
  16. "top": {
  17. "media.alerts": 10
  18. }
  19. },
  20. "lld": {
  21. "stats": "extend",
  22. "top": {
  23. "values": 5
  24. }
  25. }
  26. },
  27. "result": {
  28. "data": {
  29. "alerting": {
  30. "alerts": 0,
  31. "top": {
  32. "media.alerts": []
  33. },
  34. "time": 0.000663
  35. },
  36. "lld": {
  37. "rules": 0,
  38. "values": 0,
  39. "top": {
  40. "values": []
  41. },
  42. "time": 0.000442
  43. }
  44. },
  45. "status": "0"
  46. }
  47. }
  48. ],
  49. "id": 1
  50. }

See also

Source

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