How to Configure Zabbix Notifications
Introduction
Zabbix is an open-source software that monitors the availability and performance of IT infrastructure components. Zabbix server can be installed on any Linux distribution.
Zabbix provides real-time monitoring of thousands of metric data that it fetches from servers, virtual machines, network devices, and web applications. Analyzing the data Zabbix gathers will give you a general idea of the health of your servers and web applications, in addition to helping you detect potential problems before your users report them.
Zabbix has several methods for collecting metrics. These include agentless monitoring of user services and client-server architecture.
To monitor a server and collect data from it, Zabbix uses an agent that gathers data from different services and sends it to the Zabbix monitoring server. Zabbix supports encrypted communication between the monitoring server and its monitored clients. This ensures that your data is transferred securely over the network.
Zabbix provides a web interface that allows you to monitor your servers (also known as Zabbix clients) and their internal services and manage system settings.
In this tutorial, you will set up email notifications for monitoring a server with Zabbix.
Prerequisites
To follow this tutorial, you need:
- A Zabbix monitoring server that will have the Zabbix server installed. See How to Install Zabbix on Ubuntu 22.04 for our guide to learn how to install Zabbix.
- A Zabbix monitored client that will have the Zabbix agent installed and will be monitored using the Zabbix web interface that's installed on the monitoring server. See our How to Use Zabbix to Monitor an Ubuntu Server guide to learn how to monitor a server.
Zabbix supports multiple types of notifications: Email, Slack, Telegram, SMS, and many others. This tutorial will show you how to configure email notifications.
Setting up your Email
To set up email notifications, click on Administration on the Lefthand menu of the Zabbix web interface, then click Media Types. Then click on Email.
You can adjust the SMTP options to match the settings of your email service. This tutorial will use Gmail's SMTP.
Gmail users should type in smtp.gmail.com
in the SMTP server field. 465
for the SMTP port field. gmail.com
for the SMTP helo. Then add your email address in the SMTP email field. Next, choose SSL/TLS for the Connection security field, and Username and password for Authentication. Type in your email address for the Username field, and for the Password field, enter your Google App Password. Click Update as a final step.
You can now test sending notifications.
Click the Test underlined button.
A pop-up window will appear. Enter your email address into the Send to field, then click Test. You should receive a test successful message at the top of the widget.
Close the pop-up by clicking the Cancel button.
Next, create a new user. In the left navigation bar, click on Administration and then Users. A list of users will appear. Next, click on the Create user button at the top-right corner of your screen.
In the Alias field, enter your username and create a new password. Next, add this user to the administrator’s group. In the Groups field, type in Zabbix administrators and then select the group from the list.
Next, in the Media tab, click on the Add underlined link. A pop-up titled Media should appear.
Choose the Email option from Type drop-down menu. In the Send to box, enter your email address. The rest of the options can be left as is. Finally, click the Add button.
Next, in the Permissions tab. From the User type drop-down menu, select Zabbix Super Admin. Then click Add to create the user.
Warning:
Using the default password is not safe. In order to change the password of the built-in user 'Admin' click on it. Then click 'Change password'.
You will now need to enable notifications. Click on the Configuration tab, then click on Actions. A pre-configured action will appear. This will allow you to send notifications to all Zabbix administrators. Click on the name to review and modify its settings. The default parameters will be used for this tutorial. To enable it, click on the Disabled button in the Status column.
You are now ready to start receiving alerts.
Generating and Sending an Email Test Alert
This step will create a test alert that verifies everything is connected. We will create a large file that triggers a notification, because Zabbix automatically tracks the free space on your server. The check takes place every hour, so it may take a while before the notification is triggered.
Make a temporary file large enough to trigger Zabbix’s file system usage alert.
Log in to your monitored server with SSH, then, find out how much space you have left on your server using df
:
df -h
The command df
will show you how much your file system is using in terms of disk space. The -h
tells df
to show human-readable output:
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 38G 1G 37G 2% /
Here, the free space is 37 GB. So, to trigger a Zabbix you can use the fallocate
command to create a large temporary file that takes up 35 GB of your disk space:
fallocate -l 35G /tmp/temp.img
Zabbix will send you an alert about the amount of free disk space and it will run the action which you configured for sending the notification message. This may take about an hour. You can check your inbox for the message from the Zabbix server, and you should see a warning message that tells you that your disk space is low.
To view the notification and details, you can also navigate to the Zabbix Dashboard and the Monitoring tab.
You can then delete the test file to free up space on you server:
rm -f /tmp/temp.img
This should make the alert disappear on the Zabbix web interface.
Congrats
You now have a mechanism to monitor your server with email notifications. To find out more about Zabbix notifications, take a look at the Zabbix documentation.
A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.
If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.