The method allows to retrieve triggers according to the given parameters. 此方法允许根据指定的参数检索触发器。
Parameters 参数
(object)
Parameters defining the desired output. (object)
定义需要输出的参数。 The method supports the following parameters. 该方法支持以下参数。
(integer/array)
Returns either: 返回两者其中任一:
an array of objects; 一组对象;
the count of retrieved objects, if the
countOutput
parameter has been used. 如果已经使用了countOutput
参数,则检索对象的计数。
Examples 范例
Retrieving data by trigger ID 根据触发器ID检索数据
Request 请求:
Response 响应:
{
"jsonrpc": "2.0",
"result": [
{
"functions": [
{
"functionid": "13513",
"itemid": "24350",
"function": "diff",
"parameter": "0"
}
],
"triggerid": "14062",
"expression": "{13513}>0",
"description": "/etc/passwd has been changed on {HOST.NAME}",
"url": "",
"status": "0",
"priority": "2",
"lastchange": "0",
"comments": "",
"error": "",
"templateid": "10016",
"type": "0",
"state": "0",
"flags": "0",
"recovery_mode": "0",
"recovery_expression": "",
"correlation_mode": "0",
"manual_close": "0"
}
],
"id": 1
}
Retrieving triggers in problem state 检索在故障状态的触发器
Retrieve the ID, name and severity of all triggers in problem state and sort them by severity in descending order. 检索在问题状态下的所有触发器的ID,名称和严重性,并按严重性级别按降序分类。
Request 请求:
Response 响应:
{
"jsonrpc": "2.0",
"result": [
{
"triggerid": "13907",
"description": "Zabbix self-monitoring processes < 100% busy",
"priority": "4"
},
{
"triggerid": "13824",
"description": "Zabbix discoverer processes more than 75% busy",
}
],
"id": 1
}
Retrieving a specific trigger with tags 使用标签检索特定的触发器
Request 请求:
Response 响应:
{
"jsonrpc": "2.0",
"result": [
{
"triggerid": "17370",
"description": "Service status",
"tags": [
{
"tag": "service",
"value": "{{ITEM.VALUE}.regsub(\"Service (.*) has stopped\", \"\\1\")}"
},
{
"tag": "error",
"value": ""
}
]
}
],
"id": 1
Source 源码
CTrigger::get() in frontends/php/include/classes/api/services/CTrigger.php. CTrigger::get()方法可在frontends/php/include/classes/api/services/CTrigger.php中参考。