Set up Email alerts in Zabbix using a Gmail account

Introduction

Zabbix is an open source monitoring software used to monitor your network, servers and other infrastructure devices. One of the reasons for setting up a Zabbix server is that you can customize alerts based on needs or severity ratings for different triggers. These alerts can be sent via email or via other media that can be customized in Zabbix server.

This document will cover step by step process of setting up alerts from Zabbix server using a Gmail account.

Steps

  • Enable less secure app access in Gmail account which will be used for sending alerts
  • Set up Email media settings in Zabbix server for users that will receive alerts
  • Link the Email media type to users
  • Defining new actions and operations to use with the Email media type specifying the conditions when this media will be used (severity/triggers)

Step 1: Enable less secure app access in your Gmail account

Please enable “Less secure apps access” in order to receive notifications from Zabbix server.

Go into your Gmail account, click on profile picture on the upper-right corner of Gmail screen, then click on Manage your Google Account button, open the Security tab and scroll down to Less secure app access and turn the button to on. After these steps, the setting should look like this:

 

Set up Email alerts in Zabbix using a Gmail account 21

Step 2: Set up Email media settings in Zabbix server

Log in into Zabbix server web interface using a web browser. Log in as the Admin user or another user who have access to Administration and Configuration.

Then under the Administration tab, open Media types and choose Email from the list of predefined items, or create another entry.

In the next screen please fill in the form with the following settings for Gmail account:
(All mandatory fields are marked with an asterisk *).

*Name: Email

Type: Email

*SMTP server: smtp.gmail.com

SMTP server port: 587

*SMTP helo: smtp.gmail.com

*SMTP email: youremailaddress@gmail.com (address used in the From field of the email)

Connection security: choose STARTTLS

SSL verify peer: unchecked

SSL verify host: unchecked

Authentication: Username and password

Username: youremailaddress@gmail.com

Password: your_email_password

Enabled: make sure this box is checked

Click on the Update button at the bottom of the form.

After these steps, your form should look like this:

Important: Make sure you can reach to host: smtp.gmail.com on port 587 and your firewall from Zabbix server does not block this connection.

Note: This is the Email address that Zabbix server will use to send email notifications.

 

Set up Email alerts in Zabbix using a Gmail account 22

Step 3: Link Email media type to users

In the Administration tab, click on Users, then select the user that will use the Email media or create a new user by clicking on the Create user button on the upper-right corner of Zabbix web

Important: The user must have at least Read permissions in order to receive notifications.

After configuring user details or reviewing them, click on the Media tab then fill in the form with the following information:

Type: Email

*Send to: youremailaddress@gmail.com (you can add here more than one Email address)

*When active: 1-7,00:00-24:00 (this field use the format d-d, hh:mm-hh:mm, if I want that this media to be active only on workdays and work hours you can specify 1-5,10:00-18:00)

Use if severity: select the best option for your company, depending on which trigger severity you want to receive email alerts for.

Enable: make sure this is checked

Your media tab should look like this:

Set up Email alerts in Zabbix using a Gmail account 23

Click on Update button on the bottom of the form screen

Back on the Media tab screen, make sure correct information about Email media have been added and the status for this media is enabled. Then click on the Update button again to save the changes.

Users screen should look like this:

Set up Email alerts in Zabbix using a Gmail account 24

Note: This is the Email address that the user will receive the alerts on.

Step 4: Defining new actions and operations to use with the Email media type specifying the conditions when this media will be used

Delivering notifications in Zabbix is made possible by Actions.

Note: We need to define at least one action and operation for this email notification action.

a) Into Configuration tab, click Actions.

Click on the predefined “Report problems to Zabbix administrators” action or click on Create action button on the upper right side of your Zabbix web interface.

On the Action tab fill in the form:

*Name: Give a name for this action, Ex: “Test action”

Conditions: Define when this “Test action” will be used. This procedure/case, will choose to use this Action if trigger severity is greater or equals warning (Predefined conditions will be listed here, if there aren’t any, this field will be empty)

New Conditions (example):
From drop-down, change “Trigger name” label with “Trigger severity”

From “equals” drop-down, choose “is greater than or equals
From “Not classified” drop-down, choose Warning
Click Add button.
This condition should appear into the conditions field on a successful validation.

Enabled: make sure this is checked.

Don’t click on Update button yet.

Set up Email alerts in Zabbix using a Gmail account 25

b) Into the same menu, choose the Operations tab. Fill in the form:

* Default operation step duration: (default is 1h; for testing purposes, this was changed to 1m)

Default subject and default message fields can be used to customize your email notifications content.
We recommend modifying Default subject field like this: Problem: {EVENT.NAME} on Host: {HOST.NAME}

Leave Pause operations for suppressed problems checkbox activated and while screen will look like this:

Set up Email alerts in Zabbix using a Gmail account 26

Click on New into the Operations field. A new form will open. Fill in as follows:

Steps: 1 – 1 (I will leave it as it is)

Step duration: 0 (I will leave it as it is)

Operation type: Choose Send message

Send to User groups: In our example case only Admin user will receive notifications, so this field is empty.

Send to Users: Click Add button, then select Admin (Zabbix Administrator) to send email notifications to.

Send only to: Choose Email from the drop-down.

Default message: Leave this checked.

Conditions: (Leave this empty.)

Click on the Update button at the bottom of the Operation form.

Click Update again on the bottom of the Action

After these steps, your Operations tab should look like this:

Set up Email alerts in Zabbix using a Gmail account 27

Actions menu should see new operation(s) defined and should will look like this:

Set up Email alerts in Zabbix using a Gmail account 28

Click on the Update button again

c) Verify if new Action has been linked to the Email media type defined.

Go into Administration → Media types and check if new added Test action is linked to Email media defined, it should look like this:

Set up Email alerts in Zabbix using a Gmail account 29

d) Test if your email notifications really work:

This can be tested using a predefined Trigger with High severity, on Item agent.ping
If Zabbix agent is turned off on the monitored host or if the host is down for some time, notifications should be received about this event in configured email account.
Also, email notifications status can be seen on Monitoring → Dashboard screen on Zabbix server web interface, and in our test case looks like this:

Set up Email alerts in Zabbix using a Gmail account 30

– Verify Email account to confirm received notifications.

Troubleshooting

  • Make sure all steps are followed exactly. Verify them again if some steps in the process seem unsure.
  • Make sure firewall does not block any connection to the smtp.gmail.com on port 587
  • Zabbix server firewall or by case your network firewall
  • Make sure Gmail account used to send notifications has “Allow less secure app access” option activated.