Configure email alert in Zabbix3.0

Source: Internet
Author: User

Configure email alert in Zabbix3.0

After setting up the Zabbix server and creating monitoring metrics and triggers, how can I use my mailbox to enable the alarm function? This article uses mail as the mail sending tool.

The following describes how to install and configure a mailbox.

Let's just talk about it! We will install the mail sending tool in two steps, and configure the Zabbix server to send alarm emails in the second step.

1. Install and set up mail

Install email support

Yum install postfix

Systemctl start postfix

Systemctl enable postfix

Verification: ss-lntp

Install mail

Yum-y install bzip2 openssl-devel wget patch gcc-c ++
Cd/opt
Wget http://nchc.dl.sourceforge.net/project/heirloom/heirloom-mailx/12.4/mailx-12.4.tar.bz2
Tar jxvf mailx-12.4.tar.bz2 # Extract
Cd mailx-12.4 # Go To The Directory
Wget http://www.linuxfromscratch.org/patches/blfs/7.6/mailx-12.4-openssl_1.0.0_build_fix-1.patch # download Patch pack
Patch-Np1-I mailx-12.4-openssl_1.0.0_build_fix-1.patch # patch pack
Make # compile
Make install UCBINSTALL =/usr/bin/install # install
Ln-s/usr/local/bin/mailx/bin/mail # create a soft connection from mailx to mail
Ln-s/etc/nail. rc/etc/mail. rc # create a soft connection to the mailx configuration file
Whereis mailx # view the installation path
Mailx-V # view version information

Edit sender and email server information

Vi/etc/nail. rc
Add the configuration file:
Set from = xxxxxx0@163.com # set the default sender
Set smtp = smtp.163.com # smtp Server
Set smtp-auth-user = xxxxxx@163.com # set the sender mailbox for authentication
Set smtp-auth-password = 12345678 # logon password
Set smtp-auth = login # Allow Logon
(Modify email information according to your own situation !)

Restart --> systemctl restart postfix

Test email sending

Echo "email content" | mail-s "Email Subject" xxxxxx @ 163 (recipient's email address)
For example:
Echo "--- Hello Word! --- "| Mail-s" Message "xxxxxx@163.com

Detailed description of mail Command Parameters

-B <address>: Specify the recipient address of the BCC copy;
-C <address>: Specifies the recipient address of the copy;
-F <email file>: reads emails in the specified email file;
-I: do not display the information sent by the terminal;
-I: Use the interactive mode;
-N: when the program is used, the setting in the mail. rc file is not used;
-N: when reading an email, the email title is not displayed;
-S <Email Subject>: Specifies the subject of the email;
-U <user account>: reads emails of a specified user;
-V: detailed information is displayed during execution.

Ii. Zabbix Server Configuration

Configure the zabbix configuration file vim/etc/zabbix/zabbix_server.conf

AlertScriptsPath =/usr/lib/zabbix/alertscripts # put the mail sending script in the configuration path

Script content:

[Root @ zabbix_server alertscripts] # cat sendmail. sh
#! /Bin/sh
Messages = 'echo $3 | tr' \ r \ n' \ N''
Subject = 'echo $2 | tr' \ r \ n' \ N''
Echo "$ {messages}" | mail-s "$ {subject}" $1>/tmp/sendmail. log 2> & 1

Restart zabbix

Configure zabbix graphical -- manage -- Alarm media type -- create media type in the upper right corner -- input three parameters

{ALERT. SENDTO} -- recipient address

{ALERT. SUBJECT} -- Topic

{ALERT. MESSAGE} -- body

Text

Configure the recipient and user permissions -- manage -- user -- Alarm media -- select the sendemail. sh script and enter the recipient's email address.

Add permission -- manage -- User Group -- select Zabbix administrator Group

Click "permission" to add the monitored group.

Configure -- Action -- edit mail sending operation

Configure the sending action and Message format

Alert HOST: {HOSTNAME1} <br/>
Alert address: {IPADDRESS} <br/>
Alert TIME: {EVENT. DATE} {EVENT. TIME} <br/>
Alert Level: {TRIGGER. SEVERITY} <br/>
Alert Information: {TRIGGER. NAME} <br/>
Alert item: {TRIGGER. KEY1} <br/>
Problem details: {ITEM. NAME }:& nbsp; {ITEM. VALUE} <br/>
Current STATUS: {TRIGGER. STATUS }:& nbsp; {ITEM. VALUE1} <br/>
Event id: {EVENT. ID}

Configuration-action-operation

The modification duration is 60 seconds.

Step 3: trigger three actions

Select User Admin

Select to send only to sendEmail. sh

Click Update

Restore Information subject:

Alert HOST: {TRIGGER. NAME} <br/>
Alert address: {IPADDRESS} <br/>
Alert TIME: {EVENT. DATE} {EVENT. TIME} <br/>
Current STATUS: {TRIGGER. STATUS} <br/>
Alert Level: {TRIGGER. SEVERITY} <br/>
Alert URL: {TRIGGER. URL} <br/>

Item values: <br/>

1. {ITEM. NAME1} ({HOST. NAME1 }:{ ITEM. KEY1}): {ITEM. VALUE1} <br/>
2. {ITEM. NAME2} ({HOST. NAME2 }:{ ITEM. KEY2}): {ITEM. VALUE2} <br/>
3. {ITEM. NAME3} ({HOST. NAME3 }:{ ITEM. KEY3}): {ITEM. VALUE3} <br/>

Configuration complete!

Click Report> Action Log to view the email sending status !!!

Raise a question !! Thank you !!

More Zabbix Tutorials:

Install Zabbix 16.04 on Ubuntu 3.2 Server

Set up Zabbix3.0 in CentOS 7 LNMP Environment

Install and deploy the monitoring system Zabbix2.4 on Ubuntu 16.04

Zabbix monitoring installation and deployment and alarm Configuration

Detailed description of the Zabbix trigger expression

Install and deploy Zabbix3.0 in Ubuntu 16.04

Under CentOS 6.3, Zabbix monitors apache server-status

How to install Zabbix 3.0 in CentOS 7

Install Zabbix 2.0.6 in 64-bit CentOS 6.2

Zabbix 3.2.6 monitor Oracle database through Orabbix

ZABBIX details: click here
ZABBIX: click here

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.