整数/数组 event.get(object parameters)
此方法用于根据给定参数来获取事件。
(对象) 定义所需输出的参数。
此方法支持以下参数:
| 参数 类 | 描述 | |
|---|---|---|
| eventids | string/array | 仅返回具有给定ID的事件。 | 
| groupids | string/array | 仅返回所属主机组的对象创建的事件。 | 
| hostids | string/array | 仅返回所属主机的对象创建的事件。 | 
| objectids | string/array | 仅返回由给定对象创建的事件。 | 
| applicationids | string/array | 仅返回所属应用的对象创建的事件。仅当对象为触发器或监控项时才适用。 | 
| source | integer | 仅返回给定类型的事件。 有关支持的事件类型的列表,请参阅事件对象页面. 默认值: 0 - 触发器事件。 | 
| object | integer | 仅返回由给定类型的对象创建的事件。 有关支持的对象类型的列表,请参阅事件对象页面. 默认值: 0 - 触发器。 | 
| acknowledged | boolean | 若设置为“true”,则只返回已被确认的事件。 | 
| severities | integer/array | 仅返回符合所属严重程度的事件。仅当对象为触发器时才适用。 | 
| evaltype | integer | 标签搜索的规则。 可能值: 0 - (默认) 与/或; 2 - 或。 | 
| tags | object | 仅返回具有给定标签的事件。 按标签进行完全匹配,按值搜索时,不区分大小写。 Format: [{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...].一个空数组会返回所有事件。 可能的操作类型: 0 - (默认) 相似(like); 1 - 相等(equal)。 | 
| eventid_from | string | 仅返回ID大于或等于给定ID的事件。 | 
| eventid_till | string | 仅返回ID小于或等于给定ID的事件。 | 
| time_from | timestamp | 仅返回在给定时间时或之后创建的事件。 | 
| time_till | timestamp | 仅返回在给定时间时或之前创建的事件。 | 
| value | integer/array | 仅返回具有给定值的事件。 | 
| selectHosts | query | 在 主机属性下,返回包含创建该事件的对象的主机. 仅支持由触发器、监控项、低级别发现规则生成的事件。 | 
| selectRelatedObject | query | 在 相关对象(relatedObject)属性下,返回创建该事件的对象。返回的对象类型会依赖于该事件的类型。 | 
| select_alerts | query | 在 告警属性下,返回由该事件生成的告警,告警是按反向时间顺序进行排序。 | 
| select_acknowledges | query | 在 确认属性下,返回事件的更新. 事件的更新是按反向时间顺序进行排序。事件更新对象具有以下属性: acknowledgeid-(string)确认的ID;userid-(string)更新事件的用户的ID;eventid-(string)被更新事件的ID;clock-(timestamp)事件的更新时间;message-(string)消息文本;action-(integer)已执行的更新操作,参考event.acknowledge;old_severity-(integer)event severity before this update action更新操作之前的事件的严重等级;new_severity-(integer)更新操作之后的事件的严重等级;alias-(string)alias of the user that updated the event更新该事件的用户的别名;name-(string)更新该事件的用户的名称;surname-(string)更新该事件的用户的姓氏.支持 计数(count)。 | 
| selectTags | query | 在 标签属性下,返回事件的标签。 | 
| sortfield | string/array | 根据给定属性,对结果进行排序。 可能值: eventid,objectid以及clock。 | 
| countOutput | boolean | 以下参数为get方法通常参数,在参考注释有详细说明。 | 
| editable | boolean | |
| excludeSearch | boolean | |
| filter | object | |
| limit | integer | |
| output | query | |
| preservekeys | boolean | |
| search | object | |
| searchByAny | boolean | |
| searchWildcardsEnabled | boolean | |
| sortorder | string/array | |
| startSearch | boolean | |
(整数/数组) 返回:
countOutput 参数,返回获取对象的数值。从触发器"13926."中获取最新事件。
请求:
{
           "jsonrpc": "2.0",
           "method": "event.get",
           "params": {
               "output": "extend",
               "select_acknowledges": "extend",
               "selectTags": "extend",
               "objectids": "13926",
               "sortfield": ["clock", "eventid"],
               "sortorder": "DESC"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }响应:
{
           "jsonrpc": "2.0",
           "result": [
               {
                   "acknowledges": [
                       {
                           "acknowledgeid": "1",
                           "userid": "1",
                           "eventid": "9695",
                           "clock": "1350640590",
                           "message": "Problem resolved.\n\r----[BULK ACKNOWLEDGE]----",
                           "action": "6",
                           "old_severity": "0",
                           "new_severity": "0",
                           "alias": "Admin",
                           "name": "Zabbix",
                           "surname": "Administrator"
                       }
                   ],
                   "eventid": "9695",
                   "source": "0",
                   "object": "0",
                   "objectid": "13926",
                   "clock": "1347970410",
                   "value": "1",
                   "acknowledged": "1",
                   "ns": "413316245",
                   "name": "MySQL is down",
                   "severity": "5",
                   "r_eventid": "0",
                   "c_eventid": "0",
                   "correlationid": "0",
                   "userid": "0",
                   "tags": [
                       {
                           "tag": "service",
                           "value": "mysqld"
                       },
                       {
                           "tag": "error",
                           "value": ""
                       }
                   ]
               },
               {
                   "acknowledges": [],
                   "eventid": "9671",
                   "source": "0",
                   "object": "0",
                   "objectid": "13926",
                   "clock": "1347970347",
                   "value": "0",
                   "acknowledged": "0",
                   "ns": "0",
                   "name": "Unavailable by ICMP ping",
                   "severity": "4",
                   "r_eventid": "0",
                   "c_eventid": "0",
                   "correlationid": "0",
                   "userid": "0",
                   "tags": []
               }
           ],
           "id": 1
       }在2012-10-9至2012-10-10时间段内,以反向时间顺序获取所有已被创建的事件。
请求:
{
           "jsonrpc": "2.0",
           "method": "event.get",
           "params": {
               "output": "extend",
               "time_from": "1349797228",
               "time_till": "1350661228",
               "sortfield": ["clock", "eventid"],
               "sortorder": "desc"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }响应:
{
           "jsonrpc": "2.0",
           "result": [
               {
                   "eventid": "20616",
                   "source": "0",
                   "object": "0",
                   "objectid": "14282",
                   "clock": "1350477814",
                   "value": "1",
                   "acknowledged": "0",
                   "ns": "0",
                   "name": "Less than 25% free in the history cache",
                   "severity": "3",
                   "r_eventid": "0",
                   "c_eventid": "0",
                   "correlationid": "0",
                   "userid": "0"
               },
               {
                   "eventid": "20617",
                   "source": "0",
                   "object": "0",
                   "objectid": "14283",
                   "clock": "1350477814",
                   "value": "0",
                   "acknowledged": "0",
                   "ns": "0",
                   "name": "Zabbix trapper processes more than 75% busy",
                   "severity": "3",
                   "r_eventid": "0",
                   "c_eventid": "0",
                   "correlationid": "0",
                   "userid": "0"
               },
               {
                   "eventid": "20618",
                   "source": "0",
                   "object": "0",
                   "objectid": "14284",
                   "clock": "1350477815",
                   "value": "1",
                   "acknowledged": "0",
                   "ns": "0",
                   "name": "High ICMP ping loss",
                   "severity": "3",
                   "r_eventid": "0",
                   "c_eventid": "0",
                   "correlationid": "0",
                   "userid": "0"
               }
           ],
           "id": 1
       }CEvent::get() in frontends/php/include/classes/api/services/CEvent.php.