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 响应:

    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. "priority": "2",
    19. "lastchange": "0",
    20. "comments": "",
    21. "error": "",
    22. "templateid": "10016",
    23. "type": "0",
    24. "state": "0",
    25. "flags": "0",
    26. "recovery_mode": "0",
    27. "recovery_expression": "",
    28. "correlation_mode": "0",
    29. "manual_close": "0"
    30. }
    31. ],
    32. "id": 1
    33. }

    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 响应:

    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. }
    13. ],
    14. "id": 1
    15. }

    Retrieving a specific trigger with tags 使用标签检索特定的触发器

    Request 请求:

    Response 响应:

    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

    Source 源码

    CTrigger::get() in frontends/php/include/classes/api/services/CTrigger.php. CTrigger::get()方法可在frontends/php/include/classes/api/services/CTrigger.php中参考。