创建

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 参数Type 类型Description 说明
dependenciesarray 数组Triggers and trigger prototypes that the trigger prototype is dependent on. 依赖触发器原型的触发器和触发器原型。

The triggers must have the triggerid property defined. 触发器必须已定义triggerid属性。
tagsarray 数组Trigger 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 请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "triggerprototype.create",
  4. "params": {
  5. "description": "Free disk space is less than 20% on volume {#FSNAME}",
  6. "expression": "{Zabbix server:vfs.fs.size[{#FSNAME},pfree].last()}<20",
  7. "tags": [
  8. {
  9. "tag": "volume",
  10. "value": "{#FSNAME}"
  11. },
  12. {
  13. "tag": "type",
  14. "value": "{#FSTYPE}"
  15. }
  16. ]
  17. },
  18. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  19. "id": 1
  20. }

Response 响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "triggerids": [
  5. "17372"
  6. ]
  7. },
  8. "id": 1
  9. }

Source 源码

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