> Action object

下面是动作(action)API 相关的对象。

动作

动作对象具有以下属性。

属性 类描述
actionidstring(readonly) 动作的 ID。
esc_period
(required)
string默认操作步骤持续时间。必须大于 60 秒。接受秒,带后缀的时间单位和用户宏。
eventsource
(required)
integer(constant) 动作将处理的事件的类型。

参见 event “source” property 以获取支持的事件类型列表。
name
(required)
string动作的名称。
def_longdatastring异常消息文本。
def_shortdatastring异常消息主题。
r_longdatastring恢复消息文本。
r_shortdatastring恢复消息主题。
ack_longdatastring确认操作消息文本。
ack_shortdatastring确认操作消息主题。
statusinteger动作是启动还是禁用。

取值:
0 - (默认) 启用;
1 - 禁用。
pause_suppressedinteger是否在维护期间暂停升级。

可能的值:
0 - 不要暂停升级;
1 - (默认) 暂停升级。

动作操作

动作操作对象定义执行动作时执行的操作。它具有以下属性。

属性 类描述
operationidstring(readonly) 动作操作的 ID。
operationtype
(required)
integer操作类型

可能的值:
0 - 发送消息;
1 - 远程命令;
2 - 添加主机;
3 - 删除主机;
4 - 添加到主机组;
5 - 从主机组删除;
6 - 链接到模板;
7 - 取消与模板的关联;
8 - 启用主机;
9 - 禁用主机;
10 - 设置主机库存模式。
actionidstring操作所属的动作的 ID。
esc_periodstring以秒为单位的升级步骤的持续时间。必须大于 60 秒。接受秒,时间单位后缀和用户宏。如果设置为 0 或0s,则将使用默认的动作升级周期。

默认: 0s.
esc_step_frominteger步骤开始升级。

默认: 1.
esc_step_tointeger步骤结束升级。

默认: 1.
evaltypeinteger运行状态计算方法。

可能的值:
0 - (默认) AND / OR;
1 - AND;
2 - OR.
opcommandobject包含操作所运行的命令的数据。

操作命令对象是 described in detail below.

远程命令操作所需的。
opcommand_grparray运行远程命令的主机组。

每个对象具有以下属性:
opcommand_grpid - (string, readonly) 对象的 ID;
operationid - (string) 操作 ID;
groupid - (string) 主机组的 ID。

如果没有设置 opcommand_hst,则需要远程命令操作。
opcommand_hstarray主机上运行远程命令。

每个对象具有以下属性:
opcommand_hstid - (string, readonly) 对象的 ID;
operationid - (string) 操作 ID;
hostid - (string) 主机 ID; 如果设置为 0,则命令将在当前主机上运行。

如果没有设置 opcommand_grp,则需要远程命令操作。
opconditionsarray用于触发动作的操作条件

操作条件对象是 下面详细描述.
opgrouparray用于添加主机的主机组。

每个对象都具有以下属性:
operationid - (string) ID of the operation;
groupid - (string) 主机组的 ID。

添加到主机组从主机组中删除 操作所必需的。
opmessageobject包含有关操作发送的消息的数据的对象。

操作消息对象是 下面详细描述.

消息操作必需。
opmessage_grparray要发送消息的用户组。

每个对象都具有以下属性:
operationid - (string) 操作 ID;
usrgrpid - (string) 用户组的ID。

如果未设置 opmessage_usr,则消息操作必需。
opmessage_usrarray发送消息给的用户。

每个对象都具有以下属性:
operationid - (string) 操作 ID;
userid - (string) 用户的ID。

如果未设置 opmessage_grp,则消息操作必需。
optemplatearray用于将主机链接到的模板。

每个对象都具有以下属性:
operationid - (string) 操作 ID;
templateid - (string) 模板 ID.

必须有 “link to template” 和 “unlink from template” 操作
opinventoryobject库存模式设置主机。

每个对象都具有以下属性:
operationid - (string) 操作 ID;
inventory_mode - (string) Inventory mode.

需要有 “Set host inventory mode” 操作。

动作操作命令

操作命令对象包含有关运行操作命令的数据。

属性 类说明
operationidstring(readonly) 操作 ID.
commandstring要运行的命令。 当类型为 (0,1,2,3) 时,此项是必须的
type
(required)
integer操作命令的类型

可能的值:
0 - custom script;
1 - IPMI;
2 - SSH;
3 - Telnet;
4 - global script.
authtypeintegerSSH 命令的认证方法。

可能的值:
0 - password;
1 - public key.

Required for SSH commands.
execute_oninteger将要执行自定义脚本操作命令的目标。

可能的值:
0 - Zabbix agent;
1 - Zabbix server;
2 - Zabbix server (proxy).

自定义脚本命令所需的。
passwordstring密码验证和 telnet 命令时用于 SSH 命令的密码。
portstring用于 SSH 和 telnet 命令的端口号。
privatekeystring使用公钥认证的 SSH 命令的私钥文件的名称。

具有密钥验证的 SSH 命令所必需的。
publickeystring用于SSH公钥和公钥认证的公钥名称。

具有密钥验证的 SSH 命令所必需的。
scriptidstring用于全局脚本命令的脚本 ID。

需要全局脚本命令。
usernamestring用于登录认证的用户名

使用 SSH 和 Telnet 命令时是必须的.

动作操作消息

操作消息对象包含有关将由操作发送的消息的数据。

属性 类说明
operationidstring(readonly) 动作操作的 ID
default_msginteger是否使用默认动作消息文本和主题。

可能的值:
0 - (default) 使用操作中的消息文本和主题
1 - 使用动作中的消息文本和主题
mediatypeidstring将用于发送消息的媒体类型ID。
messagestring操作消息文本。
subjectstring操作消息主题。

动作操作条件

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

属性 类说明
opconditionidstring(readonly) 动作操作条件的 ID
conditiontype
(required)
integer条件的类型。

可能的值:
14 - event acknowledged.
value
(required)
string与之比较的值。
operationidstring(readonly) 动作操作的 ID
operatorinteger条件运算符

可能的值:
0 - (default) =.

每个操作条件类型都支持以下运算符和值。

条件 条名称 支持的运算期望值
14Event acknowledged=件是否被确认。

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

Action recovery operation

The action recovery operation object defines an operation that will be performed when a problem is resolved. Recovery operations are possible for trigger actions and internal actions. It has the following properties.

PropertyTypeDescription
operationidstring(readonly) ID of the action operation.
operationtype
(required)
integerType of operation.

Possible values for trigger actions:
0 - send message;
1 - remote command;
11 - notify all involved.

Possible values for internal actions:
0 - send message;
11 - notify all involved.
actionidstringID of the action that the recovery operation belongs to.
opcommandobjectObject containing the data about the command run by the recovery operation.

The operation command object is described in detail above.

Required for remote command operations.
opcommand_grparrayHost groups to run remote commands on.

Each object has the following properties:
opcommand_grpid - (string, readonly) ID of the object;
operationid - (string) ID of the operation;
groupid - (string) ID of the host group.

Required for remote command operations if opcommand_hst is not set.
opcommand_hstarrayHost to run remote commands on.

Each object has the following properties:
opcommand_hstid - (string, readonly) ID of the object;
operationid - (string) ID of the operation;
hostid - (string) ID of the host; if set to 0 the command will be run on the current host.

Required for remote command operations if opcommand_grp is not set.
opmessageobjectObject containing the data about the message sent by the recovery operation.

The operation message object is described in detail above.

Required for message operations.
opmessage_grparrayUser groups to send messages to.

Each object has the following properties:
operationid - (string) ID of the operation;
usrgrpid - (string) ID of the user group.

Required for message operations if opmessage_usr is not set.
opmessage_usrarrayUsers to send messages to.

Each object has the following properties:
operationid - (string) ID of the operation;
userid - (string) ID of the user.

Required for message operations if opmessage_grp is not set.

Action acknowledge operation

The action acknowledge operation object defines an operation that will be performed when a problem is acknowledged. Acknowledge operations are possible for trigger actions. It has the following properties.

PropertyTypeDescription
operationidstring(readonly) ID of the action operation.
operationtype
(required)
integerType of operation.

Possible values for trigger actions:
0 - send message;
1 - remote command;
12 - notify all involved.
opcommandobjectObject containing the data about the command run by the recovery operation.

The operation command object is described in detail above.

Required for remote command operations.
opcommand_grparrayHost groups to run remote commands on.

Each object has the following properties:
groupid - (string) ID of the host group.

Required for remote command operations if opcommand_hst is not set.
opcommand_hstarrayHost to run remote commands on.

Each object has the following properties:
hostid - (string) ID of the host; if set to 0 the command will be run on the current host.

Required for remote command operations if opcommand_grp is not set.
opmessageobjectObject containing the data about the message sent by the recovery operation.

The operation message object is described in detail above.
opmessage_grparrayUser groups to send messages to.

Each object has the following properties:
usrgrpid - (string) ID of the user group.

Required only for send message operations if opmessage_usr is not set.
Is ignored for send acknowledge message operations.
opmessage_usrarrayUsers to send messages to.

Each object has the following properties:
userid - (string) ID of the user.

Required only for send message operations if opmessage_grp is not set.
Is ignored for send acknowledge message operations.

Action filter

The action filter object defines a set of conditions that must be met to perform the configured action operations. It has the following properties.

PropertyTypeDescription
conditions
(required)
arraySet of filter conditions to use for filtering results.
evaltype
(required)
integerFilter condition evaluation method.

Possible values:
0 - and/or;
1 - and;
2 - or;
3 - custom expression.
eval_formulastring(readonly) Generated expression that will be used for evaluating filter conditions. The expression contains IDs that reference specific filter conditions by its formulaid. The value of eval_formula is equal to the value of formula for filters with a custom expression.
formulastringUser-defined expression to be used for evaluating conditions of filters with a custom expression. The expression must contain IDs that reference specific filter conditions by its formulaid. The IDs used in the expression must exactly match the ones defined in the filter conditions: no condition can remain unused or omitted.

Required for custom expression filters.

Action filter condition

The action filter condition object defines a specific condition that must be checked before running the action operations.

PropertyTypeDescription
conditionidstring(readonly) ID of the action condition.
conditiontype
(required)
integerType of condition.

Possible values for trigger actions:
0 - host group;
1 - host;
2 - trigger;
3 - trigger name;
4 - trigger severity;
6 - time period;
13 - host template;
15 - application;
16 - maintenance status;
25 - event tag;
26 - event tag value.

Possible values for discovery actions:
7 - host IP;
8 - discovered service type;
9 - discovered service port;
10 - discovery status;
11 - uptime or downtime duration;
12 - received value;
18 - discovery rule;
19 - discovery check;
20 - proxy;
21 - discovery object.

Possible values for auto-registration actions:
20 - proxy;
22 - host name;
24 - host metadata.

Possible values for internal actions:
0 - host group;
1 - host;
13 - host template;
15 - application;
23 - event type.
value
(required)
stringValue to compare with.
value2
stringSecondary value to compare with. Requried for trigger actions when condition type is 26.
actionidstring(readonly) ID of the action that the condition belongs to.
formulaidstringArbitrary unique ID that is used to reference the condition from a custom expression. Can only contain capital-case letters. The ID must be defined by the user when modifying filter conditions, but will be generated anew when requesting them afterward.
operatorintegerCondition operator.

Possible values:
0 - (default) =;
1 - <>;
2 - like;
3 - not like;
4 - in;
5 - >=;
6 - <=;
7 - not in.

To better understand how to use filters with various types of expressions, see examples on the action.get and action.create method pages.

The following operators and values are supported for each condition type.

ConditionCondition nameSupported operatorsExpected value
0Host group=, <>Host group ID.
1Host=, <>Host ID.
2Trigger=, <>Trigger ID.
3Trigger namelike, not likeTrigger name.
4Trigger severity=, <>, >=, <=Trigger severity. Refer to the trigger “severity” property for a list of supported trigger severities.
5Trigger value=Trigger value. Refer to the trigger “value” property for a list of supported trigger values.
6Time periodin, not inTime when the event was triggered as a time period.
7Host IP=, <>One or several IP ranges to check separated by commas. Refer to the network discovery configuration section for more information on supported formats of IP ranges.
8Discovered service type=, <>Type of discovered service. The type of service matches the type of the discovery check used to detect the service. Refer to the discovery check “type” property for a list of supported types.
9Discovered service port=, <>One or several port ranges separated by commas.
10Discovery status=Status of a discovered object.

Possible values:
0 - host or service up;
1 - host or service down;
2 - host or service discovered;
3 - host or service lost.
11Uptime or downtime duration>=, <=Time indicating how long has the discovered object been in the current status in seconds.
12Received values=, <>, >=, <=, like, not likeValue returned when performing a Zabbix agent, SNMPv1, SNMPv2 or SNMPv3 discovery check.
13Host template=, <>Linked template ID.
15Application=, like, not likeName of the application.
16Maintenance statusin, not inNo value required: using the “in” operator means that the host must be in maintenance, “not in” - not in maintenance.
18Discovery rule=, <>ID of the discovery rule.
19Discovery check=, <>ID of the discovery check.
20Proxy=, <>ID of the proxy.
21Discovery object=Type of object that triggered the discovery event.

Possible values:
1 - discovered host;
2 - discovered service.
22Host namelike, not likeHost name.
23Event type=Specific internal event.

Possible values:
0 - item in “not supported” state;
1 - item in “normal” state;
2 - LLD rule in “not supported” state;
3 - LLD rule in “normal” state;
4 - trigger in “unknown” state;
5 - trigger in “normal” state.
24Host metadatalike, not likeMetadata of the auto-registered host.
25Tag=, <>, like, not likeEvent tag.
26Tag value=, <>, like, not likeEvent tag value.

The following objects are directly related to the action API.

Action

The action object has the following properties.

PropertyTypeDescription
actionidstring(readonly) ID of the action.
esc_period
(required)
stringDefault operation step duration. Must be greater than 60 seconds. Accepts seconds, time unit with suffix and user macro.
eventsource
(required)
integer(constant) Type of events that the action will handle.

Refer to the event “source” property for a list of supported event types.
name
(required)
stringName of the action.
def_longdatastringProblem message text.
def_shortdatastringProblem message subject.
r_longdatastringRecovery message text.
r_shortdatastringRecovery message subject.
ack_longdatastringAcknowledge operation message text.
ack_shortdatastringAcknowledge operation message subject.
statusintegerWhether the action is enabled or disabled.

Possible values:
0 - (default) enabled;
1 - disabled.
pause_suppressedintegerWhether to pause escalation during maintenance periods or not.

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

Action operation

The action operation object defines an operation that will be performed when an action is executed. It has the following properties.

PropertyTypeDescription
operationidstring(readonly) ID of the action operation.
operationtype
(required)
integerType of operation.

Possible values:
0 - send message;
1 - remote command;
2 - add host;
3 - remove host;
4 - add to host group;
5 - remove from host group;
6 - link to template;
7 - unlink from template;
8 - enable host;
9 - disable host;
10 - set host inventory mode.
actionidstringID of the action that the operation belongs to.
esc_periodstringDuration of an escalation step in seconds. Must be greater than 60 seconds. Accepts seconds, time unit with suffix and user macro. If set to 0 or 0s, the default action escalation period will be used.

Default: 0s.
esc_step_fromintegerStep to start escalation from.

Default: 1.
esc_step_tointegerStep to end escalation at.

Default: 1.
evaltypeintegerOperation condition evaluation method.

Possible values:
0 - (default) AND / OR;
1 - AND;
2 - OR.
opcommandobjectObject containing the data about the command run by the operation.

The operation command object is described in detail below.

Required for remote command operations.
opcommand_grparrayHost groups to run remote commands on.

Each object has the following properties:
opcommand_grpid - (string, readonly) ID of the object;
operationid - (string) ID of the operation;
groupid - (string) ID of the host group.

Required for remote command operations if opcommand_hst is not set.
opcommand_hstarrayHost to run remote commands on.

Each object has the following properties:
opcommand_hstid - (string, readonly) ID of the object;
operationid - (string) ID of the operation;
hostid - (string) ID of the host; if set to 0 the command will be run on the current host.

Required for remote command operations if opcommand_grp is not set.
opconditionsarrayOperation conditions used for trigger actions.

The operation condition object is described in detail below.
opgrouparrayHost groups to add hosts to.

Each object has the following properties:
operationid - (string) ID of the operation;
groupid - (string) ID of the host group.

Required for “add to host group” and “remove from host group” operations.
opmessageobjectObject containing the data about the message sent by the operation.

The operation message object is described in detail below.

Required for message operations.
opmessage_grparrayUser groups to send messages to.

Each object has the following properties:
operationid - (string) ID of the operation;
usrgrpid - (string) ID of the user group.

Required for message operations if opmessage_usr is not set.
opmessage_usrarrayUsers to send messages to.

Each object has the following properties:
operationid - (string) ID of the operation;
userid - (string) ID of the user.

Required for message operations if opmessage_grp is not set.
optemplatearrayTemplates to link the hosts to to.

Each object has the following properties:
operationid - (string) ID of the operation;
templateid - (string) ID of the template.

Required for “link to template” and “unlink from template” operations.
opinventoryobjectInventory mode set host to.

Object has the following properties:
operationid - (string) ID of the operation;
inventory_mode - (string) Inventory mode.

Required for “Set host inventory mode” operations.

Action operation command

The operation command object contains data about the command that will be run by the operation.

PropertyTypeDescription
operationidstring(readonly) ID of the operation.
commandstringCommand to run. Required when type IN (0,1,2,3)
type
(required)
integerType of operation command.

Possible values:
0 - custom script;
1 - IPMI;
2 - SSH;
3 - Telnet;
4 - global script.
authtypeintegerAuthentication method used for SSH commands.

Possible values:
0 - password;
1 - public key.

Required for SSH commands.
execute_onintegerTarget on which the custom script operation command will be executed.

Possible values:
0 - Zabbix agent;
1 - Zabbix server;
2 - Zabbix server (proxy).

Required for custom script commands.
passwordstringPassword used for SSH commands with password authentication and Telnet commands.
portstringPort number used for SSH and Telnet commands.
privatekeystringName of the private key file used for SSH commands with public key authentication.

Required for SSH commands with public key authentication.
publickeystringName of the public key file used for SSH commands with public key authentication.

Required for SSH commands with public key authentication.
scriptidstringID of the script used for global script commands.

Required for global script commands.
usernamestringUser name used for authentication.

Required for SSH and Telnet commands.

Action operation message

The operation message object contains data about the message that will be sent by the operation.

PropertyTypeDescription
operationidstring(readonly) ID of the action operation.
default_msgintegerWhether to use the default action message text and subject.

Possible values:
0 - (default) use the data from the operation;
1 - use the data from the action.
mediatypeidstringID of the media type that will be used to send the message.
messagestringOperation message text.
subjectstringOperation message subject.

Action operation condition

The action operation condition object defines a condition that must be met to perform the current operation. It has the following properties.

PropertyTypeDescription
opconditionidstring(readonly) ID of the action operation condition
conditiontype
(required)
integerType of condition.

Possible values:
14 - event acknowledged.
value
(required)
stringValue to compare with.
operationidstring(readonly) ID of the operation.
operatorintegerCondition operator.

Possible values:
0 - (default) =.

The following operators and values are supported for each operation condition type.

ConditionCondition nameSupported operatorsExpected value
14Event acknowledged=Whether the event is acknowledged.

Possible values:
0 - not acknowledged;
1 - acknowledged.

Action filter condition

The action filter condition object defines a specific condition that must be checked before running the action operations.

PropertyTypeDescription
conditionidstring(readonly) ID of the action condition.
conditiontype
(required)
integerType of condition.

Possible values for trigger actions:
0 - host group;
1 - host;
2 - trigger;
3 - trigger name;
4 - trigger severity;
6 - time period;
13 - host template;
15 - application;
16 - maintenance status;
25 - event tag;
26 - event tag value.

Possible values for discovery actions:
7 - host IP;
8 - discovered service type;
9 - discovered service port;
10 - discovery status;
11 - uptime or downtime duration;
12 - received value;
18 - discovery rule;
19 - discovery check;
20 - proxy;
21 - discovery object.

Possible values for auto-registration actions:
20 - proxy;
22 - host name;
24 - host metadata.

Possible values for internal actions:
0 - host group;
1 - host;
13 - host template;
15 - application;
23 - event type.
value
(required)
stringValue to compare with.
value2
stringSecondary value to compare with. Requried for trigger actions when condition type is 26.
actionidstring(readonly) ID of the action that the condition belongs to.
formulaidstringArbitrary unique ID that is used to reference the condition from a custom expression. Can only contain capital-case letters. The ID must be defined by the user when modifying filter conditions, but will be generated anew when requesting them afterward.
operatorintegerCondition operator.

Possible values:
0 - (default) =;
1 - <>;
2 - like;
3 - not like;
4 - in;
5 - >=;
6 - <=;
7 - not in.

To better understand how to use filters with various types of expressions, see examples on the action.get and action.create method pages.

The following operators and values are supported for each condition type.

ConditionCondition nameSupported operatorsExpected value
0Host group=, <>Host group ID.
1Host=, <>Host ID.
2Trigger=, <>Trigger ID.
3Trigger namelike, not likeTrigger name.
4Trigger severity=, <>, >=, <=Trigger severity. Refer to the trigger “severity” property for a list of supported trigger severities.
5Trigger value=Trigger value. Refer to the trigger “value” property for a list of supported trigger values.
6Time periodin, not inTime when the event was triggered as a time period.
7Host IP=, <>One or several IP ranges to check separated by commas. Refer to the network discovery configuration section for more information on supported formats of IP ranges.
8Discovered service type=, <>Type of discovered service. The type of service matches the type of the discovery check used to detect the service. Refer to the discovery check “type” property for a list of supported types.
9Discovered service port=, <>One or several port ranges separated by commas.
10Discovery status=Status of a discovered object.

Possible values:
0 - host or service up;
1 - host or service down;
2 - host or service discovered;
3 - host or service lost.
11Uptime or downtime duration>=, <=Time indicating how long has the discovered object been in the current status in seconds.
12Received values=, <>, >=, <=, like, not likeValue returned when performing a Zabbix agent, SNMPv1, SNMPv2 or SNMPv3 discovery check.
13Host template=, <>Linked template ID.
15Application=, like, not likeName of the application.
16Maintenance statusin, not inNo value required: using the “in” operator means that the host must be in maintenance, “not in” - not in maintenance.
18Discovery rule=, <>ID of the discovery rule.
19Discovery check=, <>ID of the discovery check.
20Proxy=, <>ID of the proxy.
21Discovery object=Type of object that triggered the discovery event.

Possible values:
1 - discovered host;
2 - discovered service.
22Host namelike, not likeHost name.
23Event type=Specific internal event.

Possible values:
0 - item in “not supported” state;
1 - item in “normal” state;
2 - LLD rule in “not supported” state;
3 - LLD rule in “normal” state;
4 - trigger in “unknown” state;
5 - trigger in “normal” state.
24Host metadatalike, not likeMetadata of the auto-registered host.
25Tag=, <>, like, not likeEvent tag.
26Tag value=, <>, like, not likeEvent tag value.