trigger.get

Description说明

integer/array trigger.get(object parameters)该方法用于指定的参数检索触发器.

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 只返回指定时间之前更改其状态的触发器.
onlytrue 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 flagThese 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

Return values

(integer/array) Returns either返回两者其中任一:

  • 一组对象;

  • 如果已经使用了“countOutput”参数,则检索对象的计数.

范例

从触发器ID中检索数据

检索触发器“14062”中使用的所有数据和功能.

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "trigger.get",
  4. "params": {
  5. "triggerids": "14062",
  6. "output": "extend",
  7. "selectFunctions": "extend"
  8. },
  9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "functions": [
  6. {
  7. "functionid": "13513",
  8. "itemid": "24350",
  9. "function": "diff",
  10. "parameter": "0"
  11. }
  12. ],
  13. "triggerid": "14062",
  14. "expression": "{13513}>0",
  15. "description": "/etc/passwd has been changed on {HOST.NAME}",
  16. "url": "",
  17. "status": "0",
  18. "value": "0",
  19. "priority": "2",
  20. "lastchange": "0",
  21. "comments": "",
  22. "error": "",
  23. "templateid": "10016",
  24. "type": "0",
  25. "state": "0",
  26. "flags": "0",
  27. "recovery_mode": "0",
  28. "recovery_expression": "",
  29. "correlation_mode": "0",
  30. "correlation_tag": "",
  31. "manual_close": "0"
  32. }
  33. ],
  34. "id": 1
  35. }

在问题状态下检索触发器

检索在问题状态下的所有触发器的ID,名称和严重性,并按严重性级别按降序分类。.

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "trigger.get",
  4. "params": {
  5. "output": [
  6. "triggerid",
  7. "description",
  8. "priority"
  9. ],
  10. "filter": {
  11. "value": 1
  12. },
  13. "sortfield": "priority",
  14. "sortorder": "DESC"
  15. },
  16. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  17. "id": 1
  18. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "triggerid": "13907",
  6. "description": "Zabbix self-monitoring processes < 100% busy",
  7. "priority": "4"
  8. },
  9. {
  10. "triggerid": "13824",
  11. "description": "Zabbix discoverer processes more than 75% busy",
  12. "priority": "3"
  13. }
  14. ],
  15. "id": 1
  16. }

使用标签检索特定触发器

使用标签检索特定触发器.

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "trigger.get",
  4. "params": {
  5. "output": [
  6. "triggerid",
  7. "description"
  8. ],
  9. "selectTags": "extend",
  10. "triggerids": [
  11. "17578"
  12. ]
  13. },
  14. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  15. "id": 1
  16. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "triggerid": "17370",
  6. "description": "Service status",
  7. "tags": [
  8. {
  9. "tag": "service",
  10. "value": "{{ITEM.VALUE}.regsub(\"Service (.*) has stopped\", \"\\1\")}"
  11. },
  12. {
  13. "tag": "error",
  14. "value": ""
  15. }
  16. ]
  17. }
  18. ],
  19. "id": 1
  20. }

参考

来源

CTrigger::get() in frontends/php/include/classes/api/services/CTrigger.php.