trigger.create
Description说明
object trigger.create(object/array triggers)
This method allows to create new triggers此方法允许创建新的触发器.
Parameters参数
(object/array)
Triggers to create需要去创建的触发器.
Additionally to the standard trigger properties the method accepts the following parameters.除standard trigger properties之外,该方法接受以下参数。
Parameter参数 | Type类型 | Description说明 |
---|---|---|
dependencies | array | Triggers that the trigger is dependent on触发触发器依赖. The triggers must have the triggerid property defined触发器必须定义triggerid 属性. |
tags | array | Trigger tags触发器标签. |
The trigger expression has to be given in its expanded form触发器表达式必须以其扩展形式给出.
Return values返回值
(object)
Returns an object containing the IDs of the created triggers under the triggerids
property. The order of the returned IDs matches the order of the passed triggers.(object)
返回一个包含triggerids
属性下创建触发器的ID的对象.返回的ID的顺序与传递的触发器的顺序相匹配。
Examples范例
Creating a trigger创建一个触发器
Create a trigger with a single trigger dependency创建具有单个触发依赖关系的触发器.
Request请求:
- {
- "jsonrpc": "2.0",
- "method": "trigger.create",
- "params": [
- {
- "description": "Processor load is too high on {HOST.NAME}",
- "expression": "{Linux server:system.cpu.load[percpu,avg1].last()}>5",
- "dependencies": [
- {
- "triggerid": "17367"
- }
- ]
- },
- {
- "description": "Service status",
- "expression": "{Linux server:log[/var/log/system,Service .* has stopped].strlen()}<>0",
- "dependencies": [
- {
- "triggerid": "17368"
- }
- ],
- "tags": [
- {
- "tag": "service",
- "value": "{{ITEM.VALUE}.regsub(\"Service (.*) has stopped\", \"\\1\")}"
- },
- {
- "tag": "error",
- "value": ""
- }
- ]
- }
- ],
- "auth": "038e1d7b1735c6a5436ee9eae095879e",
- "id": 1
- }
Response响应:
- {
- "jsonrpc": "2.0",
- "result": {
- "triggerids": [
- "17369",
- "17370"
- ]
- },
- "id": 1
- }
Source来源
CTrigger::create() in frontends/php/include/classes/api/services/CTrigger.php.