Sidebar

Zabbix Summit 2022
Register for Zabbix Summit 2022

2 操作

2 Operations

概述

Overview

您可以为所有事件定义以下操作:

You can define the following operations for all events:

  • 发送信息
  • 执行远程命令 (包括 IPMI)
  • send a message
  • execute a remote command (including IPMI)

<note important>如果用户被明确地设置了主机动作(action)和操作(opertion)权限为"denied"或用户根本没有该主机的访问权限,那么Zabbix server并不产生告警。 :::

Zabbix server does not create alerts if access to the host is explicitly "denied" for the user defined as action operation recipient or if the user has no rights defined to the host at all.

对于发现事件,还有其他操作可用:

For discovery and auto-registration events, there are additional operations available:

  • 添加主机
  • 删除主机
  • 启用主机
  • 禁用主机
  • 添加到主机群组
  • 从主机群组中删除
  • 链接到模板
  • 取消与模板的链接
  • 设置主机资产清单
  • add host
  • remove host
  • enable host
  • disable host
  • add to host group
  • remove from host group
  • link to template
  • unlink from template
  • set host inventory mode

配置操作

Configuring an operation

要配置操作,进入action 配置 中的 操作 选项卡,然后单击操作块中的 New。编辑操作步骤,然后单击 Add 添加到 Operations列表中。

To configure an operation, go to the Operations tab in action configuration and click on New in the Operations block. Edit the operation step and click on Add to add to the list of Operations.

操作属性:

Operation attributes:

All mandatory input fields are marked with a red asterisk.

参数
Default operation step duration 一个操作步骤默认持续时间(最少60秒).
例如,一小时的持续时间意味着如果执行操作,则在下一步之前将经过一小时.
Default subject 默认消息主题为通知. 主题可能包含.
Default message 通知的默认消息. 消息可能包含 .
Pause operations while in maintenance 标记此复选框以延长维护期间的操作.\\如果取消选中此复选框,即使在维护期间,操作也将立即执行.
Zabbix 3.2.0之后支持此选项.
Operations 显示操作操作,具体如下:
Steps - 分配操作的升级步骤
Details - 操作类型及其收件人/目标.
自Zabbix 2.2以来,操作列表还显示了发送消息中使用的媒体类型(电子邮件,SMS,Jabber等)以及通知收件人的名称和姓氏(在别名之后的括号中)
Start in -执行操作后的事件多长时间
Duration (sec) - 显示步长。 如果步骤使用默认持续时间,则显示Default如果使用自定义持续时间,则显示时间。
Action - 显示用于编辑和删除操作的链接。
要配置新操作,请单击New.
Operation details 此块用于配置操作的详细信息.
Steps 升级计划表中选择步骤分配操作:
From - 从这一步开始执行
To - 执行到此步骤 (0=infinity, 执行不会受到限制)
Step duration 这些步骤的自定义持续时间(0 =使用默认步骤持续时间).
几个操作可以分配到同一步骤. 如果这些操作具有不同的步长定义,则考虑最短的步骤并将其应用于该步骤.
Operation type 所有事件都有两种操作类型:
Send message - 发送消息给用户
Remote command - 执行远程命令
更多的操作可用于发现和基于自动注册的事件(见上文).
操作类型: 发信息
Send to user groups 点击 Add 选择要发送消息的用户组.
用户组必须至少具有“读取” 权限以获得主机的通知.
Send to users 点击Add 选择要发送消息的用户.
用户组必须至少具有“读取” 权限 以获得主机的通知.
Send only to 发送消息到所有定义的媒体类型或只选一个.
Default message 如果选择,将使用默认消息(见上文).
Subject 自定义消息的主题. 主题可能包含宏.
Message 自定义消息. 消息可能包含宏。
操作类型: 远程命令
Target list 选择要执行命令的目标:
Current host - 命令在导致问题事件的触发器的主机上执行.如果触发器中有多个主机,则此选项将无法正常工作.
Host - 选择主机以执行命令.
Host group -选择主机组以执行命令. 指定父主机组隐含地选择所有嵌套的主机组.因此,远程命令也将在嵌套组的主机上执行.
主机上的命令只能执行一次,即使主机与多次匹配(例如来自多个主机组,单独地和从主机组匹配).
如果在Zabbix服务器上执行命令,目标列表是无意义的, 在这种情况下选择更多目标只会导致服务器上执行的命令更多次.
请注意,对于全局脚本,目标选择也取决于全局脚本配置中设置的 主机组 .
Type 选择命令类型:
IPMI - 执行IPMI 命令
Custom script - 执行一组自定义的命令
SSH - 执行SSH命令
Telnet - 执行Telnet命令
Global script - 执行管理 - >脚本中定义的全局脚本之一.
Execute on 在Zabbix服务器或Zabbix代理上执行自定义脚本. 要在代理上执行脚本,它必须是配置为 允许来自服务器的远程命令.
如果选择“自定义脚本”作为类型,则该字段可用.
Commands 输入命令.
支持的宏将根据导致事件的触发表达式进行解析. 例如,主机宏将解析为主机的触发器表达式(而不是目标列表).
Conditions 执行操作的条件:
Not ack - 只有当事件未被确认时
Ack - 只有事件被确认时.
Parameter Description
Default operation step duration Duration of one operation step by default (60 seconds to 1 week).
For example, an hour-long step duration means that if an operation is carried out, an hour will pass before the next step.
Time suffixes are supported, e.g. 60s, 1m, 2h, 1d, since Zabbix 3.4.0.
User macros are supported, since Zabbix 3.4.0.
Default subject Default message subject for notifications. The subject may contain macros. It is limited to 255 characters.
Default message Default message for notifications. The message may contain macros. It is limited to certain amount of characters depending on the type of database (see Sending message for more information).
Pause operations while in maintenance Mark this checkbox to delay the start of operations for the duration of a maintenance period. When operations are started, after the maintenance, all operations are performed including those for the events during the maintenance.
If you unmark this checkbox, operations will be executed without delay even during a maintenance period.
This option is supported since Zabbix 3.2.0.
Operations Action operations are displayed, with these details:
Steps - escalation step(s) to which the operation is assigned
Details - type of operation and its recipient/target.
Since Zabbix 2.2, the operation list also displays the media type (e-mail, SMS, Jabber, etc) used in sending a message as well as the name and surname (in parentheses after the alias) of a notification recipient.
Start in - how long after an event the operation is performed
Duration (sec) - step duration is displayed. Default is displayed if the step uses default duration, and a time is displayed if custom duration is used.
Action - links for editing and removing an operation are displayed.
To configure a new operation, click on New.
Operation details This block is used to configure the details of an operation.
Steps Select the step(s) to assign the operation to in an escalation schedule:
From - execute starting with this step
To - execute until this step (0=infinity, execution will not be limited)
Step duration Custom duration for these steps (0=use default step duration).
Time suffixes are supported, e.g. 60s, 1m, 2h, 1d, since Zabbix 3.4.0.
User macros are supported, since Zabbix 3.4.0.
Several operations can be assigned to the same step. If these operations have different step duration defined, the shortest one is taken into account and applied to the step.
Operation type Two operation types are available for all events:
Send message - send message to user
Remote command - execute a remote command
More operations are available for discovery and auto-registration based events (see above).
Operation type: send message
Send to user groups Click on Add to select user groups to send the message to.
The user group must have at least "read" permissions to the host in order to be notified.
Send to users Click on Add to select users to send the message to.
The user must have at least "read" permissions to the host in order to be notified.
Send only to Send message to all defined media types or a selected one only.
Default message If selected, the default message will be used (see above).
Subject Subject of the custom message. The subject may contain macros. It is limited to 255 characters.
Message The custom message. The message may contain macros. It is limited to certain amount of characters depending on the type of database (see Sending message for more information).
Operation type: remote command
Target list Select targets to execute the command on:
Current host - command is executed on the host of the trigger that caused the problem event. This option will not work if there are multiple hosts in the trigger.
Host - select host(s) to execute the command on.
Host group - select host group(s) to execute the command on. Specifying a parent host group implicitly selects all nested host groups. Thus the remote command will also be executed on hosts from nested groups.
A command on a host is executed only once, even if the host matches more than once (e.g. from several host groups; individually and from a host group).
The target list is meaningless if a custom script is executed on Zabbix server. Selecting more targets in this case only results in the script being executed on the server more times.
Note that for global scripts, the target selection also depends on the Host group setting in global script configuration.
Type Select the command type:
IPMI - execute an IPMI command
Custom script - execute a custom set of commands
SSH - execute an SSH command
Telnet - execute a Telnet command
Global script - execute one of the global scripts defined in Administration→Scripts.
Execute on Execute a custom script on:
Zabbix agent - the script will be executed by Zabbix agent on the host
Zabbix server (proxy) - the script will be executed by Zabbix server or proxy - depending on whether the host is monitored by server or proxy
Zabbix server - the script will be executed by Zabbix server only
To execute scripts on the agent, it must be configured to allow remote commands from the server.
To execute scripts on proxy, it must be configured to allow remote commands from the server.
This field is available if 'Custom script' is selected as Type.
Commands Enter the command(s).
Supported macros will be resolved based on the trigger expression that caused the event. For example, host macros will resolve to the hosts of the trigger expression (and not of the target list).
Conditions Condition for performing the operation:
Not ack - only when the event is unacknowledged
Ack - only when the event is acknowledged.