integer/array trigger.get(object parameters)
该方法用于指定的参数检索触发器.
(object)
定义所需输出的参数。
该方法提供以下参数.
参数 类 | 说明 | |
---|---|---|
triggerids | string/array | 只返回指定 ID 的触发器. |
groupids | string/array | 只返回指定主机组所属主机的触发器. |
templateids | string/array | 只返回指定模板的触发器. |
hostids | string/array | 只返回指定主机所属的触发器. |
itemids | string/array | 只返回指定监控项所属的触发器. |
applicationids | string/array | 只返回指定应用集包含监控项所属的触发器. |
functions | string/array | 只返回指定函数所属的触发器. 有关支持的功能列表,请参阅supported trigger functions页面 |
group | string | 只返回指定名称的主机组中属于主机的触发器. |
host | string | 只返回指定名称的主机的触发器. |
inherited | boolean | 如果设置为“true”,则只返回从模板继承的触发器. |
templated | boolean | 如果设置为“true”,则只返回所属模板的触发器. |
monitored | flag | 只返回所属被监控主机启用触发器,且包含已启用的监控项. |
active | flag | 只返回所属被监控主机的已启用触发器. |
maintenance | boolean | 如果设置为“true”,则只返回所属维护中主机的已启用触发器. |
withUnacknowledgedEvents | flag | 只返回具有未确认事件的触发器. |
withAcknowledgedEvents | flag | 只返回所有事件确认的触发器. |
withLastEventUnacknowledged | flag | 只返回最后一个未确认事件的触发器. |
skipDependent | flag | 在依赖于其他触发器的问题状态中跳过触发器。 请注意:如果禁用,禁用监控项或禁用主机监控项,其他触发器将被忽略 |
lastChangeSince | timestamp | 只返回指定时间之后改变状态的触发器. |
lastChangeTill | timestamp | 只返回指定时间之前更改其状态的触发器. |
only_true | flag | 只返回最近处于问题状态的触发器. |
min_severity | integer | 只返回严重级别大于或等于给定严重性的触发器. |
expandComment | flag | 在触发器注释中扩展宏. |
expandDescription | flag | 以触发器的名称扩展宏. |
expandExpression | flag | 扩展触发器表达式中的函数和宏. |
selectGroups | query | 在groups 属性中返回触发器所属的主机组. |
selectHosts | query | 在hosts 属性中返回触发器所属的主机. |
selectItems | query | 在items 属性中返回触发器所包含的监控项. |
selectFunctions | query | Return functions used in the trigger in the functions property.函数对象表示触发器表达式中使用的函数,并具有以下属性: functionid - (string) 函数的ID;itemid - (string) 函数中使用的监控项的ID;function - (string) 函数名称;parameter - (string) 参数传递给函数. |
selectDependencies | query | 返回触发器依赖于dependencies 属性的触发器. |
selectDiscoveryRule | query | 返回创建触发器的低水平发现规则. |
selectLastEvent | query | 返回lastEvent 属性中的最后一个重要触发事件. |
selectTags | query | 在“标签”属性中返回触发器标记. |
filter | object | 只返回与给定过滤器完全匹配的结果. 接受一个数组,其中keys是属性名称,并且值是单个值或要匹配值的数组. 支持新增的过滤器: host - technical name of the host that the trigger belongs to触发器所属主机的技术性名称;hostid - ID of the host that the trigger belongs to触发器所属主机的ID. |
limitSelects | integer | 限制子选择返回的记录数. 适用于以下子选择: selectHosts - results will be sorted by host 结果将按host 分类. |
sortfield | string/array | Sort the result by the given properties给定属性的结果. Possible values are可能的值为: triggerid , description , status , priority , lastchange and和 hostname . |
countOutput | flag | These parameters being common for all get methods are described in detail in the reference commentary page这些参数对于所有的get 方法是常见的,在reference commentsary页面中有详细描述. |
editable | boolean | |
excludeSearch | flag | |
limit | integer | |
output | query | |
preservekeys | flag | |
search | object | |
searchByAny | boolean | |
searchWildcardsEnabled | boolean | |
sortorder | string/array | |
startSearch | flag |
(integer/array)
Returns either返回两者其中任一:
检索触发器“14062”中使用的所有数据和功能.
请求:
{
"jsonrpc": "2.0",
"method": "trigger.get",
"params": {
"triggerids": "14062",
"output": "extend",
"selectFunctions": "extend"
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
响应:
{
"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",
"value": "0",
"priority": "2",
"lastchange": "0",
"comments": "",
"error": "",
"templateid": "10016",
"type": "0",
"state": "0",
"flags": "0",
"recovery_mode": "0",
"recovery_expression": "",
"correlation_mode": "0",
"correlation_tag": "",
"manual_close": "0"
}
],
"id": 1
}
检索在问题状态下的所有触发器的ID,名称和严重性,并按严重性级别按降序分类。.
请求:
{
"jsonrpc": "2.0",
"method": "trigger.get",
"params": {
"output": [
"triggerid",
"description",
"priority"
],
"filter": {
"value": 1
},
"sortfield": "priority",
"sortorder": "DESC"
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
响应:
{
"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",
"priority": "3"
}
],
"id": 1
}
使用标签检索特定触发器.
请求:
{
"jsonrpc": "2.0",
"method": "trigger.get",
"params": {
"output": [
"triggerid",
"description"
],
"selectTags": "extend",
"triggerids": [
"17578"
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
响应:
{
"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
}
CTrigger::get() in frontends/php/include/classes/api/services/CTrigger.php.