动作 object

以下objects与actionAPI直接相关。

Action

action 对象具有以下属性。

Property Type Description
actionid ID action 的 ID。

Property behavior:
- read-only
- required for update operations
esc_period string 默认操作步骤持续时间。必须至少为 60 秒。可接受秒数、带后缀的时间单位或用户宏。

Property behavior:
- 当 eventsource 设置为 "event created by a trigger"、"internal event" 或 "event created on service status update" 时,supported
eventsource integer action 将处理的事件类型。

有关支持的事件类型列表,请参阅 event source property

Property behavior:
- constant
- required for create operations
name string action 的名称。

Property behavior:
- required for create operations
status integer action 是启用还是禁用。

Possible values:
0 - (default) enabled;
1 - disabled.
pause_symptoms integer 当事件为症状事件时,是否暂停升级。

Possible values:
0 - Don't pause escalation for symptom problems;
1 - (default) Pause escalation for symptom problems.

Property behavior:
- 当 eventsource 设置为 "event created by a trigger" 时,supported
pause_suppressed integer 在维护期间是否暂停升级。

Possible values:
0 - Don't pause escalation;
1 - (default) Pause escalation.

Property behavior:
- 当 eventsource 设置为 "event created by a trigger" 时,supported
notify_if_canceled integer 当升级被取消时是否通知。

Possible values:
0 - Don't notify when escalation is canceled;
1 - (default) Notify when escalation is canceled.

Property behavior:
- 当 eventsource 设置为 "event created by a trigger" 时,supported

Action operation

Action operation 对象定义了在执行 action 时将执行的操作。它具有以下属性。

Property Type Description
operationtype integer 操作类型。

可能的值:
0 - 发送消息;
1 - 全局脚本;
2 - 添加主机;
3 - 删除主机;
4 - 添加到主机组;
5 - 从主机组移除;
6 - 关联模板;
7 - 取消关联模板;
8 - 启用主机;
9 - 禁用主机;
10 - 设置主机清单模式;
13 - 添加主机标签;
14 - 删除主机标签。

如果 Action objecteventsource 设置为“由触发器创建的事件”或“服务状态更新时创建的事件”,则可能的值为:
0 - “发送消息”;
1 - “全局脚本”。

如果 Action objecteventsource 设置为“内部事件”,则可能的值为:
0 - “发送消息”。

Property behavior
- required
esc_period string 升级步骤的持续时间,单位为秒。必须大于 60 秒。可接受秒数、带后缀的时间单位或用户宏。如果设置为 0 或 0s,则将使用默认的 action 升级周期。

默认值:0s。

Property behavior
- 当 Action objecteventsource 设置为“由触发器创建的事件”、“内部事件”或“服务状态更新时创建的事件”时,supported
esc_step_from integer 升级开始步骤。

默认值:1。

Property behavior
- 当 Action objecteventsource 设置为“由触发器创建的事件”、“内部事件”或“服务状态更新时创建的事件”时,supported
esc_step_to integer 升级结束步骤。

默认值:1。

Property behavior
- 当 Action objecteventsource 设置为“由触发器创建的事件”、“内部事件”或“服务状态更新时创建的事件”时,supported
evaltype integer 操作条件的计算方式

可能的值:
0 - (默认) 与/或;
1 - 与;
2 - 或。
opcommand object 要执行的全局脚本。

全局脚本必须定义 scriptid 属性。

Property behavior
- 如果 operationtype 设置为“全局脚本”,则为 required
opcommand_grp array 要在其上运行全局脚本的主机组。

主机组必须定义 groupid 属性。

Property behavior
- 如果 operationtype 设置为“全局脚本”且未设置 opcommand_hst,则为 required
opcommand_hst array 要在其上运行全局脚本的主机。

主机必须定义 hostid 属性。

Property behavior
- 如果 operationtype 设置为“全局脚本”且未设置 opcommand_grp,则为 required
opconditions array 用于触发器 action 的操作条件。

操作条件对象的详细说明如下
opgroup array 要将主机添加到的主机组。

主机组必须定义 groupid 属性。

Property behavior
- 如果 operationtype 设置为“添加到主机组”或“从主机组移除”,则为 required
opmessage object 包含操作发送消息数据的对象。

操作消息对象的详细说明如下

Property behavior
- 如果 operationtype 设置为“发送消息”,则为 required
opmessage_grp array 要向其发送消息的用户组。

用户组必须定义 usrgrpid 属性。

Property behavior
- 如果 operationtype 设置为“发送消息”且未设置 opmessage_usr,则为 required
opmessage_usr array 要向其发送消息的用户。

用户必须定义 userid 属性。

Property behavior
- 如果 operationtype 设置为“发送消息”且未设置 opmessage_grp,则为 required
optemplate array 要关联到主机的模板。

模板必须定义 templateid 属性。

Property behavior
- 如果 operationtype 设置为“关联模板”或“取消关联模板”,则为 required
opinventory object 要将主机设置为的清单模式。

清单必须定义 inventory_mode 属性。

Property behavior
- 如果 operationtype 设置为“设置主机清单模式”,则为 required
optag array 要添加或删除的主机标签。

标签必须定义 tag 属性。
value 属性为可选。

Property behavior
- 如果 operationtype 设置为“添加主机标签”或“删除主机标签”,则为 supported

操作消息

操作消息对象包含将由操作发送的消息相关数据。它具有以下属性。

Property Type Description
default_msg integer 是否使用默认的动作消息正文和主题。

可能的值:
0 - 使用来自操作的数据;
1 - (默认) 使用来自媒体类型的数据。
mediatypeid ID 将用于发送消息的媒体类型 ID。

属性行为
- supported 如果 Action operation objectAction recovery operation objectAction update operation objectoperationtype 设置为 "send message",或者 Action update operation objectoperationtype 设置为 "notify all involved"
message string 操作消息正文。

属性行为
- supported 如果 default_msg 设置为 "use the data from the operation"
subject string 操作消息主题。

属性行为
- supported 如果 default_msg 设置为 "use the data from the operation"

操作条件

操作条件对象定义了执行当前操作必须满足的条件。它具有以下属性。

Property Type Description
conditiontype integer 条件类型。

可能的值:
14 - 事件已确认。

属性行为
- 必填
value string 要比较的值。

属性行为
- 必填
operator integer 条件运算符。

可能的值:
0 - (默认) =

以下运算符和值适用于每种操作条件类型。

Condition Condition name Supported operators Expected value
14 事件已确认 = 事件是否已确认。

可能的值:
0 - 未确认;
1 - 已确认。

Action 恢复操作

Action 恢复操作对象定义了在问题解决时将执行的操作。 恢复操作适用于 trigger、内部和服务 action。 它具有以下属性。

Property Type Description
operationtype integer 操作类型。

如果 Action objecteventsource 设置为“由 trigger 创建的事件”或“服务状态更新时创建的事件”,则可能的值为:
0 - 发送消息;
1 - 全局脚本;
11 - 通知所有相关人员。

如果 Action objecteventsource 设置为“内部事件”,则可能的值为:
0 - 发送消息;
11 - 通知所有相关人员。

Property behavior
- required
opcommand object 要执行的全局脚本。

全局脚本必须定义 scriptid 属性。

Property behavior
- 如果 operationtype 设置为“全局脚本”,则为 required
opcommand_grp array 要在其上运行全局脚本的主机组。

主机组必须定义 groupid 属性。

Property behavior
- 如果 Action objecteventsource 设置为“由 trigger 创建的事件”,且 operationtype 设置为“全局脚本”,并且未设置 opcommand_hst,则为 required
opcommand_hst array 要在其上运行全局脚本的主机。

主机必须定义 hostid 属性。

Property behavior
- 如果 Action objecteventsource 设置为“由 trigger 创建的事件”,且 operationtype 设置为“全局脚本”,并且未设置 opcommand_grp,则为 required
opmessage object 包含恢复操作发送消息数据的对象。

操作消息对象在上文中有详细说明

Property behavior
- 如果 operationtype 设置为“发送消息”,则为 required
opmessage_grp array 要向其发送消息的用户组。

用户组必须定义 usrgrpid 属性。

Property behavior
- 如果 operationtype 设置为“发送消息”,且未设置 opmessage_usr,则为 required
opmessage_usr array 要向其发送消息的用户。

用户必须定义 userid 属性。

Property behavior
- 如果 operationtype 设置为“发送消息”,且未设置 opmessage_grp,则为 required

Action update operation

Action 更新操作对象定义了一个在问题被更新时执行的操作 (添加评论、确认、严重性变更,或手动关闭)。 更新操作适用于 trigger 和 service action。 它具有以下属性。

Property Type Description
operationtype integer 操作类型。

可能的值:
0 - 发送消息;
1 - 全局脚本;
12 - 通知所有相关人员。

属性行为
- required
opcommand object 要执行的全局脚本。

全局脚本必须定义 scriptid 属性。

属性行为
- required if operationtype is set to "global script"
opcommand_grp array 运行全局脚本的主机组。

主机组必须定义 groupid 属性。

属性行为
- required if eventsource of Action object is set to "event created by a trigger", and operationtype is set to "global script", and opcommand_hst is not set
opcommand_hst array 运行全局脚本的主机。

主机必须定义 hostid 属性。

属性行为
- required if eventsource of Action object is set to "event created by a trigger", and operationtype is set to "global script", and opcommand_grp is not set
opmessage object 包含更新操作发送消息数据的对象。

操作消息对象在上文中有详细说明
opmessage_grp array 要发送消息的用户组。

用户组必须定义 usrgrpid 属性。

属性行为
- required if operationtype is set to "send message" and opmessage_usr is not set
opmessage_usr array 要发送消息的用户。

用户必须定义 userid 属性。

属性行为
- required if operationtype is set to "send message" and opmessage_grp is not set

动作过滤器

动作过滤器对象定义了一组必须满足的条件,以执行已配置的动作操作。它具有以下属性。

Property Type Description
conditions array 用于筛选结果的一组过滤条件。这些条件将按照它们在公式中的位置顺序进行排序。

属性行为:
- 必填
evaltype integer 过滤条件的计算方法

可能的值:
0 - And/Or;
1 - And;
2 - Or;
3 - 自定义表达式。

属性行为:
- 必填
eval_formula string 用于计算过滤条件的生成表达式。该表达式包含引用特定过滤条件的 ID,这些 ID 通过其 formulaid 标识。对于使用自定义表达式的过滤器,eval_formula 的值等于 formula 的值。

属性行为:
- 只读
formula string 用于计算采用自定义表达式的过滤器条件的用户定义表达式。该表达式必须包含引用特定过滤条件的 ID,这些 ID 通过其 formulaid 标识。表达式中使用的 ID 必须与过滤条件中定义的 ID 完全一致:不能有任何条件未使用或被省略。

属性行为:
- 必填,如果 evaltype 设置为“自定义表达式”

Action 过滤条件

Action filter condition 对象定义了一个特定条件,在执行 action 操作之前必须先检查该条件。

Property Type Description
conditiontype integer 条件类型。

如果 Action objecteventsource 设置为“由触发器创建的事件”,则可能的值为:
0 - 主机组;
1 - 主机;
2 - 触发器;
3 - 事件名称;
4 - 触发器严重性;
6 - 时间段;
13 - 主机模板;
16 - 问题已被抑制;
25 - 事件标签;
26 - 事件标签值。

如果 Action objecteventsource 设置为“由发现规则创建的事件”,则可能的值为:
7 - 主机 IP;
8 - 发现到的服务类型;
9 - 发现到的服务端口;
10 - 发现状态;
11 - 在线或离线持续时间;
12 - 接收到的值;
18 - 发现规则;
19 - 发现检查;
20 - proxy;
21 - 发现对象。

如果 Action objecteventsource 设置为“由 active agent 自动注册创建的事件”,则可能的值为:
20 - proxy;
22 - 主机名;
24 - 主机元数据。

如果 Action objecteventsource 设置为“内部事件”,则可能的值为:
0 - 主机组;
1 - 主机;
13 - 主机模板;
23 - 事件类型;
25 - 事件标签;
26 - 事件标签值。

如果 Action objecteventsource 设置为“服务状态更新时创建的事件”,则可能的值为:
25 - 事件标签;
26 - 事件标签值;
27 - 服务;
28 - 服务名称。

Property behavior:
- required
value string 要比较的值。

Property behavior:
- required
value2 string 要比较的第二个值。

Property behavior:
- required if eventsource of Action object is set to "event created by a trigger", conditiontype is set to any possible value for trigger actions, and the type of condition (see below) is "26"
- required if eventsource of Action object is set to "internal event", conditiontype is set to any possible value for internal actions, and the type of condition (see below) is "26"
- required if eventsource of Action object is set to "event created on service status update", conditiontype is set to any possible value for service actions, and the type of condition (see below) is "26"
formulaid string 用于在自定义表达式中引用该条件的任意唯一 ID。只能包含大写字母。修改过滤条件时必须由用户定义该 ID,但在之后再次请求时会重新生成。
operator integer 条件 operator

可能的值:
0 - (default) 等于;
1 - 不等于;
2 - 包含;
3 - 不包含;
4 - 属于;
5 - 大于或等于;
6 - 小于或等于;
7 - 不属于;
8 - 匹配;
9 - 不匹配;
10 - 是;
11 - 否。

要更好地理解如何将过滤器与各种表达式类型一起使用,请参见 action.getaction.create 方法页面中的示例。

以下是每种条件类型支持的运算符和值。

Condition Condition name Supported operators Expected value
0 主机组 等于,
不等于
主机组 ID。
1 主机 等于,
不等于
主机 ID。
2 触发器 等于,
不等于
触发器 ID。
3 事件名称 包含,
不包含
事件名称。
4 触发器严重性 等于,
不等于,
大于或等于,
小于或等于
触发器严重性。有关支持的触发器严重性列表,请参见 trigger severity property
5 触发器值 等于 触发器值。有关支持的触发器值列表,请参见 trigger value property
6 时间段 属于, 不属于 事件触发时的 time period
7 主机 IP 等于,
不等于
要检查的一个或多个 IP 范围,以逗号分隔。有关支持的 IP 范围格式的更多信息,请参见 network discovery configuration 部分。
8 发现到的服务类型 等于,
不等于
发现到的服务类型。服务类型与用于检测该服务的发现检查类型相匹配。有关支持类型列表,请参见 discovery check type property
9 发现到的服务端口 等于,
不等于
一个或多个端口范围,以逗号分隔。
10 发现状态 等于 发现对象的状态。

可能的值:
0 - 主机或服务在线;
1 - 主机或服务离线;
2 - 主机或服务已发现;
3 - 主机或服务丢失。
11 在线或离线持续时间 大于或等于,
小于或等于
表示发现对象当前状态持续了多长时间的秒数。
12 接收到的值 等于,
不等于,
大于或等于,
小于或等于,
包含,
不包含
执行 Zabbix agent、SNMPv1、SNMPv2 或 SNMPv3 发现检查时返回的值。
13 主机模板 等于,
不等于
关联的模板 ID。
16 问题已被抑制 是, 否 不需要值:使用“是”运算符表示问题必须被抑制,“否”表示未被抑制。
18 发现规则 等于,
不等于
发现规则的 ID。
19 发现检查 等于,
不等于
发现检查的 ID。
20 Proxy 等于,
不等于
proxy 的 ID。
21 发现对象 等于 触发发现事件的对象类型。

可能的值:
1 - 已发现的主机;
2 - 已发现的服务。
22 主机名 包含,
不包含,
匹配,
不匹配
主机名。
在自动注册条件中,运算符 matchesdoes not match 支持使用正则表达式。
23 事件类型 等于 特定内部事件。

可能的值:
0 - 监控项处于“not supported”状态;
1 - 监控项处于“normal”状态;
2 - LLD 规则处于“not supported”状态;
3 - LLD 规则处于“normal”状态;
4 - 触发器处于“unknown”状态;
5 - 触发器处于“normal”状态。
24 主机元数据 包含,
不包含,
匹配,
不匹配
自动注册主机的元数据。
运算符 matchesdoes not match 支持使用正则表达式。
25 标签 等于,
不等于,
包含,
不包含
事件标签。
26 标签值 等于,
不等于,
包含,
不包含
事件标签值。
27 服务 等于,
不等于
服务 ID。
28 服务名称 等于,
不等于
服务名称。