文档
测试

创建动作

POST
api_jsonrpc.php

请求头

参数名
类型
描述
必填
Content-Type
String
请求的 Content-Type 头部必须设置为以下值之一: application/json-rpc, application/json 或 application/jsonrequest
必填

请求参数

参数名
类型
描述
必填
jsonrpc
String
API使用的JSON-RPC协议的版本; API实现JSON-RPC版本2.0;
必填
method
String
请求方法 action.create
必填
params
JSON
请求参数
必填
filter
JSON
这个动作的动作过滤器对象。
必填
evaltype
integer
过滤条件评估方法。可能的值:0-和/或;1-和;2-或;3-自定义表达式。
必填
conditions
Array
用于筛选结果的筛选条件集。
必填
conditionid
String
操作条件的ID。
必填
conditiontype
integer
触发动作的可能值: 0-主机组; 1-主机; 2-触发; 3-触发名称; 4-触发严重性; 6-时间段; 13-主机模板; 15-申请; 16-维护状态; 25-事件代码; 26-事件代码值。 发现操作的可能值: 7-主机IP; 8-发现的服务类型; 9-发现服务端口; 10-发现状态; 11-正常运行时间或停机时间; 12-收到的价值; 18-发现规则; 19-发现检查; 20-代理; 21-发现对象。 自动注册操作的可能值: 20-代理; 22-主机名; 24-主机元数据。 内部操作的可能值: 0-主机组; 1-主机; 13-主机模板; 15-申请; 23-事件类型。
必填
value
String
要比较的价值。
必填
operations
Array
为这个动作创建的动作操作。
必填
operationid
String
操作条件的ID。
必填
operationtype
integer
触发器操作的可能值: 0—发送消息; 1-远程命令; 11-发送恢复消息。 内部操作的可能值: 0—发送消息; 11-发送恢复消息。
必填
esc_period
String
默认操作步骤持续时间。必须大于60秒。接受秒,带后缀的时间单位和用户宏。
必填
esc_step_from
integer
步骤开始升级。 默认: 1.
必填
esc_step_to
integer
逐步结束升级 默认: 1.
必填
evaltype
integer
操作条件评估方法。 可能的值: 0 - (默认) AND / OR; 1 - AND; 2 - OR.
必填
opmessage_grp
Array
发送消息的用户组。 每个对象具有以下属性: operationid - (string) 操作的 ID; usrgrpid - (string) 用户组的ID。 如果 opmessage_usr 未设置,则为消息操作所必需。
必填
operationid
String
(string) 操作的 ID;
必填
usrgrpid
String
(string) 用户组的ID。
必填
opmessage
JSON
对象包含有关操作发送的消息的数据。
必填
operationid
String
操作操作的ID。
必填
default_msg
integer
是否使用默认操作消息文本和主题。 可能值: 0-(默认)使用操作中的数据; 1-使用操作中的数据。
必填
mediatypeid
String
将用于发送消息的媒体类型的ID。
必填
opconditions
Array
用于触发动作的操作条件。 操作对象条件
必填
opconditionid
String
操作操作条件的(只读)ID
可选
conditiontype
integer
条件类型。 可能值: 14-事件已确认。
必填
value
String
要与之比较的值
必填
operationid
String
操作操作的ID。
可选
operator
integer
条件运算符。 可能值: 0-(默认值)=。
可选
opcommand_grp
Array
要在其上运行远程命令的主机组。 每个对象都具有以下属性: opcommand_grpid-(字符串,只读)对象的ID; operation ID-(string)操作的ID; group ID-(string)主机组的ID。 如果未设置opcommand\u hst,则需要远程命令操作。
必填
opcommand_grpid
String
对象的ID
可选
operationid
String
操作的ID;
可选
groupid
String
主机组的ID
可选
opcommand
JSON
对象,其中包含有关恢复操作运行的命令的数据。
必填
type
integer
操作命令的类型。 可能值: 0-自定义脚本; 1-IPMI; 2-SSH; 3-电话网; 4-全局脚本。
必填
scriptid
String
用于全局脚本命令的脚本的ID。 全局脚本命令所必需的。
必填
recovery_operations
Array
为这个动作创建恢复操作。
必填
operationtype
integer
触发器操作的可能值: 0—发送消息; 1-远程命令; 11-发送恢复消息。 内部操作的可能值: 0—发送消息; 11-发送恢复消息。
必填
acknowledge_operations
Array
为这个操作创建确认操作。
必填
operationtype
integer
触发器操作的可能值: 0—发送消息; 1-远程命令; 11-发送恢复消息。 内部操作的可能值: 0—发送消息; 11-发送恢复消息。
必填
opmessage
JSON
对象包含有关操作发送的消息的数据。
必填
default_msg
integer
是否使用默认操作消息文本和主题。 可能值: 0-(默认)使用操作中的数据; 1-使用操作中的数据。
必填
mediatypeid
String
将用于发送消息的媒体类型的ID。
必填
name
String
动作的名称
必填
eventsource
integer
常量) 动作将处理的事件的类型。Possible values for trigger events: 0 - OK; 1 - problem. Possible values for discovery events: 0 - host or service up; 1 - host or service down; 2 - host or service discovered; 3 - host or service lost. Possible values for internal events: 0 - “normal” state; 1 - “unknown” or “not supported” state.
必填
esc_period
String
升级步骤的持续时间(秒)。必须大于60秒。接受秒,时间单位后缀和用户宏。如果设置为0或0,将使用默认动作升级期。 默认: 0s.
必填
def_shortdata
String
异常消息主题。
必填
def_longdata
String
异常消息文本。
必填
id
String
请求的任意标识符;
必填
auth
String
用户认证令牌;
必填

响应参数

参数名
类型
描述
必填
jsonrpc
string
示例:2.0 API使用的JSON-RPC协议的版本; API实现JSON-RPC版本2.0;
必填
result
object
数据字典 方法返回的数据;
必填
actionids
array
数据列表 返回创建动作id列表
必填
id
number
示例:1 相应请求的标识符。
必填

说明 / 示例

请求示例 { "jsonrpc": "2.0", "method": "action.create", "params": { "name": "Trigger action", "eventsource": 0, "status": 0, "esc_period": "2m", "def_shortdata": "{TRIGGER.NAME}: {TRIGGER.STATUS}", "def_longdata": "{TRIGGER.NAME}: {TRIGGER.STATUS}\r\nLast value: {ITEM.LASTVALUE}\r\n\r\n{TRIGGER.URL}", "filter": { "evaltype": 0, "conditions": [ { "conditiontype": 1, "operator": 0, "value": "10084" }, { "conditiontype": 3, "operator": 2, "value": "memory" } ] }, "operations": [ { "operationtype": 0, "esc_period": "0s", "esc_step_from": 1, "esc_step_to": 2, "evaltype": 0, "opmessage_grp": [ { "usrgrpid": "7" } ], "opmessage": { "default_msg": 1, "mediatypeid": "1" } }, { "operationtype": 1, "esc_step_from": 3, "esc_step_to": 4, "evaltype": 0, "opconditions": [ { "conditiontype": 14, "operator": 0, "value": "0" } ], "opcommand_grp": [ { "groupid": "2" } ], "opcommand": { "type": 4, "scriptid": "3" } } ], "recovery_operations": [ { "operationtype": "11" } ], "acknowledge_operations": [ { "operationtype": "12", "opmessage": { "message": "Custom acknowledge operation message body", "subject": "Custom acknowledge operation message subject" } } ] }, "auth": "038e1d7b1735c6a5436ee9eae095879e", "id": 1 } 返回示例 { "jsonrpc": "2.0", "result": { "actionids": [ "17" ] }, "id": 1 }