Another one of the features of Zabbix is its ability to perform automated actions and operations based on predefined triggers. In this article, we will discuss how to configure and use actions and operations in Zabbix.
Actions in Zabbix
Actions are a set of predefined steps that are triggered automatically when a certain event occurs. These actions can be used to perform a wide range of tasks, such as sending notifications, executing scripts, and restarting services.
There are several types of actions that you can use to automate tasks. Here are some common types of actions and how to use them:
- Trigger actions allow you to perform actions when a trigger status changes. For example, you can configure Zabbix to send an email notification to a specific user when a trigger changes from "OK" to "PROBLEM".
- Discovery autoregistration is a feature that allows Zabbix to automatically discover new hosts on the network and add them to the monitoring system. This can save a lot of time and effort when monitoring a large number of hosts.
- Internal actions are actions that are triggered by internal events within Zabbix. For example, you can configure Zabbix to automatically add a new item to a host when a new template is linked to the host.
To create an action in Zabbix, follow these steps:
Click on "Configuration" in the main menu, and then click on the desired type of action under "Actions".
Click on the "Create action" button to create a new action.
Enter a name for the action and select the trigger that will activate the action.
Under the "Operations" tab, you can define the actions that will be performed when the trigger is activated. You can add multiple operations to a single action.
Operations in Zabbix
Operations in Zabbix are individual tasks that are performed as part of an action. The list of available operations depends on the chosen type of action.
Some of the tasks are:
- send message;
- remote commands, including IPMI and scripts.
And the ones available for discovery actions:
- Add host: Automatically adds a new host to Zabbix when a trigger is activated.
- Remove host: Automatically removes a host from Zabbix when a trigger is activated.
- Enable host: Enables monitoring for a host that has been previously disabled.
- Disable host: Disables monitoring for a host, preventing further data collection and triggering of alerts.
- Add to the group: Adds a host to a specific host group for organizational purposes.
- Delete from group: Removes a host from a specific host group.
- Link to the template: Associates a host with a specific monitoring template, which defines the checks and metrics that will be collected for that host.
- Unlink from template: Removes the association between a host and a monitoring template.
Click on the "Operations". Choose the type of operation you want to add, “Operations” works on the trigger, “Recovery operations” reacts to problems resolving, and Update operations activate on problems being updated by other users.
Choose the type of operation you want to create.
Enter the required details for the operation. For example, if you are creating a "Send message" operation, you will need to enter the recipient's email address and the message text.
As you add more operations they will get the step numbers, you can determine the time it takes for Zabbix to go from step 1 to step 2, etc, and how many times those steps are repeated.
Also you can add conditions for those operations to work, like acknowledgment of the problem, and such.
Save the operation.
We looked into configuring and using actions and operations in Zabbix that can help you automate a wide range of tasks, from sending notifications to executing scripts.