这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.
2022 Zabbix中国峰会
2022 Zabbix中国峰会

更新

说明

object triggerprototype.update(object/array triggerPrototypes)

此方法允许更新已有的触发器原型。

参数

(object/array)需要更新的触发器原型Trigger prototype propertiestriggerid属性必须在每个触发器原型中已定义,其他所有属性为可选项。只有传递过去的属性会被更新,其他所有属性仍然保持不变。 除standard trigger prototype properties之外,该方法接受以下参数。

参数 类 说明
dependencies array 依赖触发器原型的触发器和触发器原型。

触发器必须已定义triggerid属性。
tags array 触发器标签。

<note important>指定的触发器表达式必须为展开式,并且必须包含至少一个监控项原型。 :::

返回值

(object)返回一个对象,该对象包含在triggerids属性中已更新触发器原型的ID。

范例

启用触发器原型

启用一个触发器原型,即将其状态设置为0。

请求:

{
           "jsonrpc": "2.0",
           "method": "triggerprototype.update",
           "params": {
               "triggerid": "13938",
               "status": 0
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": {
               "triggerids": [
                   "13938"
               ]
           },
           "id": 1
       }

替换触发器原型标签

为触发器原型替换标签。

请求:

{
           "jsonrpc": "2.0",
           "method": "triggerprototype.update",
           "params": {
               "triggerid": "17373",
               "tags": [
                   {
                       "tag": "volume",
                       "value": "{#FSNAME}"
                   },
                   {
                       "tag": "type",
                       "value": "{#FSTYPE}"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": {
               "triggerids": [
                   "17373"
               ]
           },
           "id": 1
       }

源码

CTriggerPrototype::update()方法可在frontends/php/include/classes/api/services/CTriggerPrototype.php中参考。