创建

Description

object triggerprototype.create(object/array triggerPrototypes)

This method allows to create new trigger prototypes.

Parameters 参数

(object/array) Trigger prototypes to create. (object/array)需要创建的触发器原型。 Additionally to the standard trigger prototype properties the method accepts the following parameters. 除standard trigger prototype properties之外,此方法还接受以下参数。

Parameter 参数 T pe 类型 Des ription 说明
dependencies array 数组 T iggers and trigger prototypes that the trigger prototype is dependent on. 依赖触发器原型的触发器和触发器原型。

The triggers must have the triggerid property defined. 触发器必须已定义triggerid属性。
tags array 数组 T igger prototype tags. 触发器原型标签。

The trigger expression has to be given in its expanded form and must contain at least one item prototype. 指定的触发器表达式必须为展开式,并且必须包含至少一个监控项原型。

Return values 返回值

(object) Returns an object containing the IDs of the created trigger prototypes under the triggerids property. The order of the returned IDs matches the order of the passed trigger prototypes. (object)返回一个对象,该对象包含在triggerids属性中已创建触发器原型的ID,返回ID的顺序与传递触发器原型的顺序相匹配。

Examples 范例

Creating a trigger prototype 创建触发器原型

Create a trigger prototype to detect when a file system has less than 20% free disk space. 创建一个触发器原型来检测磁盘剩余空间是否小于20%。

Request 请求:

{
           "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
       }

Response 响应:

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

Source 源码

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