object trigger.create(object/array triggers)
此方法允许创建新的触发器.
此方法只适用于Admin和Super admin用户类型,调用该方法的权限可以在用户角色设置中被撤销. 前往 用户角色 以查看并了解更多信息.
(object/array)
要创建的触发器.
除了 标准触发器属性 之外,该方法还接受以下参数.
触发器表达式必须以扩展形式给出.
(object)
返回一个对象,该对象包含在 triggerids
属性下创建的触发器 ID,返回 的ID 顺序与传递的触发器的顺序相匹配.
创建具有单个触发依赖关系的触发器.
请求:
{
"jsonrpc": "2.0",
"method": "trigger.create",
"params": [
{
"description": "Processor load is too high on {HOST.NAME}",
"expression": "last(/Linux server/system.cpu.load[percpu,avg1])>5",
"dependencies": [
{
"triggerid": "17367"
}
]
},
{
"description": "Service status",
"expression": "length(last(/Linux server/log[/var/log/system,Service .* has stopped]))<>0",
"dependencies": [
{
"triggerid": "17368"
}
],
"tags": [
{
"tag": "service",
"value": "{{ITEM.VALUE}.regsub(\"Service (.*) has stopped\", \"\\1\")}"
},
{
"tag": "error",
"value": ""
}
]
}
],
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
响应:
CTrigger::create() in ui/include/classes/api/services/CTrigger.php.