Configure email alert and Zabbix3.0 email alert

Source: Internet
Author: User

Configure email alert and Zabbix3.0 email alert

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 postfixsystemctl start postfixsystemctl enable postfix verification: ss-lntp

Install mail

Yum-y install bzip2 openssl-devel wget patch gcc-c ++ cd/optwget http://nchc.dl.sourceforge.net/project/heirloom/heirloom-mailx/12.4/mailx-12.4.tar.bz2tar jxvf mailx-12.4.tar.bz2 # unzip cd mailx-12.4 # Enter directory wget http://www.linuxfromscratch.org/patches/blfs/7.6/mailx-12.4-openssl_1.0.0_build_fix-1.patch # download patch package 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 the version information

Edit sender and email server information

Vi/etc/nail. add the configuration file to rc: set from = xxxxxx0@163.com # set Default sender set smtp = smtp.163.com # smtp server set smtp-auth-user = xxxxxx@163.com # set authentication sender mailbox set smtp-auth-password = 12345678 # login 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 encrypted copy;-c <address>: Specify the recipient address of the copy;-f <email file>: Read the emails in the specified email file; -I: Do not display information sent by the terminal;-I: use interactive mode;-n: use of the program, do not use mail. -N: the title of the email is not displayed when reading the email;-s <Email Subject>: Specifies the subject of the email;-u <user account>: read the email of the 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/shmessages=`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

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 !!

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.