2022 Zabbix中国峰会
2022 Zabbix中国峰会

triggerprototype.create

说明

object triggerprototype.create(object/array triggerPrototypes)

该方法允许创建新的触发器原型。

参数

(object/array) 需要去创建的触发器原型。

standard trigger prototype properties 之外,此方法还接受以下参数。

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

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

<note important>触发器表达式必须以扩展形式给定,并且必须包含至少一个项目原型。 :::

返回值

(object) 返回一个包含 triggerids 属性的触发器原型 ID 的对象。返回 ID 的顺序与传递的触发器原型的顺序想匹配。

范例

创建一个触发器原型

创建一个触发器原型来检测一个文件系统剩余空间是否小于20% 。

请求:

{
           "jsonrpc": "2.0",
           "method": "triggerprototype.create",
           "params": {
               "description": "Free disk space is less than 20% on volume {#FSNAME}",
               "expression": "{Zabbix server:vfs.fs.size[{#FSNAME},pfree].last()}<20",
               "tags": [
                   {
                       "tag": "volume",
                       "value": "{#FSNAME}"
                   },
                   {
                       "tag": "type",
                       "value": "{#FSTYPE}"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

响应:

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

来源

CTriggerPrototype::create() in frontends/php/include/classes/api/services/CTriggerPrototype.php.