获取

描述

integer/array alert.get(object parameters)

该方法允许根据给定的参数检索告警。

此方法适用于任何类型的用户。可以在用户角色设置中撤销调用此方法的权限。更多信息请参见用户角色

参数

(object) 定义所需输出的参数。

该方法支持以下参数。

参数类型描述
alertidsID/array根据给定的 alertids 返回告警。
actionidsID/array根据给定的动作返回告警。
eventidsID/array根据给定的事件返回告警。
groupidsID/array根据给定的主机组对象返回告警。
hostidsID/array根据给定的主机对象返回告警。
mediatypeidsID/array根据给定的媒体类型返回告警。
objectidsID/array根据给定的对象返回告警
useridsID/array根据给定的用户返回告警。
eventobjectinteger根据给定的事件对象回告警。

请参阅事件object以获取支持的对象类型列表。

默认值:0 - 触发器。
eventsourceinteger根据给定的事件来源返回告警。

请参阅事件source以获取支持的事件类型列表。

默认值:0 - 触发器事件。
time_fromtimestamp根据给定的时间之后返回告警。
time_tilltimestamp根据给定的时间之前返回告警。
selectHostsquery返回一个 hosts 属性,包含触发动作操作的主机数据。
selectMediatypesquery返回一个 mediatypes 属性,包含一个用于消息告警的媒体类型数组。
selectUsersquery返回一个 users 属性,包含一个消息指向的用户数组。
sortfieldstring/array根据给定的属性对结果进行排序。

可能的值包括:alertidclockeventidmediatypeidsendtostatus
countOutputboolean这些参数是所有 get 方法的通用参数,具体描述请参见 参考说明
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

返回值

(integer/array) 返回以下两者之一:

  • 一个对象数组;
  • 如果使用了countOutput参数,则返回检索到的对象的数量。

示例

根据动作ID检索告警

检索由动作”3”生成的所有告警。

请求:

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

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "alertid": "1",
  6. "actionid": "3",
  7. "eventid": "21243",
  8. "userid": "1",
  9. "clock": "1362128008",
  10. "mediatypeid": "1",
  11. "sendto": "[email protected]",
  12. "subject": "PROBLEM: Zabbix agent on Linux server is unreachable for 5 minutes: ",
  13. "message": "Trigger: Zabbix agent on Linux server is unreachable for 5 minutes: \nTrigger status: PROBLEM\nTrigger severity: Not classified",
  14. "status": "0",
  15. "retries": "3",
  16. "error": "",
  17. "esc_step": "1",
  18. "alerttype": "0",
  19. "p_eventid": "0",
  20. "acknowledgeid": "0"
  21. }
  22. ],
  23. "id": 1
  24. }

另请参阅

源码位置

CAlert::get() 在 ui/include/classes/api/services/CAlert.php 文件中。