Zabbix Service-side configuration:
Operating System: Centos7_x64
1. Install a mail sender mailx tool
[email protected] ~]# Yum install mailx-y
Open The mailx configuration file and add the following information at the end:
[Email protected] ~]# vi/etc/mail.rc
Set [email protected] smtp=smtp.163.com
[Email protected] smtp-auth-password=123456
Set Smtp-auth=login
2. Test if you can send mail normally
[[email protected] ~]# echo "This is Test mail." |mail- S "Test Mail" [email protected]
Note: If you receive the message normally, the configuration is successful!
3. Write the email script
[[Email protected] ~] # cd/usr/local/zabbix/share/zabbix/alertscripts
[Email protected]]# VI sendmail.sh
#!/bin/bashfile=/tmp/zabbix_mail.txtecho "$ $" > $filedos 2unix-k $file/bin/mail-s "$ $" < $file #echo "$ $" | Mail-s "$" $ #如果发送邮件完全是英文的, you can use this only
Note: Use Dos2unix tool is to solve Zabbix The sending message is garbled.
$ is the message content defined by the front end, $ is the header defined by the front end, $ is the recipient defined by the front end
Change the script to belong to the primary group and add Execute permissions:
[Email protected]]# chown Zabbix.zabbix sendmail.sh
[Email protected]]# chmod +x sendmail.sh
The above is the server configuration, the following is the front-end configuration:
1. Create a media type
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/75/7E/wKioL1Y6z2_iS0BZAAIo0_XuZ0o368.jpg "title=" 2.png " alt= "Wkiol1y6z2_is0bzaaio0_xuz0o368.jpg"/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/75/7E/wKioL1Y6z3nxREMBAAJGhEaNbMM447.jpg "title=" 3.png " alt= "Wkiol1y6z3nxrembaajgheanbmm447.jpg"/>
2. Add recipients to the user
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/75/7E/wKioL1Y6z42iK1gIAANiWuRCzKc618.jpg "title=" 4.png " alt= "Wkiol1y6z42ik1giaaniwurczkc618.jpg"/>
3, add action 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M00/75/81/ Wkiom1y6z1ixaneyaaitc1e_3ko933.jpg "title=" 5.png "alt=" Wkiom1y6z1ixaneyaaitc1e_3ko933.jpg "/>
Configure the Operations menu first, otherwise the Action menu will not be added successfully:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/75/81/wKiom1Y6z9uDwnABAAW2aE2Le0M084.jpg "title=" 6.png " alt= "Wkiom1y6z9udwnabaaw2ae2le0m084.jpg"/>
Subject: Problem:{trigger.name}
Content:
Host: {HOSTNAME1}
Date: {EVENT. DATE} {EVENT. TIME}
Level: {TRIGGER. SEVERITY}
Problem: {Item.name}:{item. VALUE}
Item: {TRIGGER. KEY1}
Currentstatus: {TRIGGER. Status}:{item. VALUE1}
EventID: {event.id}
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/75/7E/wKioL1Y60C-h303yAAN3zeTsGW8955.jpg "title=" 7.png " alt= "Wkiol1y60c-h303yaan3zetsgw8955.jpg"/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/75/7E/wKioL1Y60D6jUIu3AAMHGMcelsk220.jpg "title=" 8.png " alt= "Wkiol1y60d6juiu3aamhgmcelsk220.jpg"/>650) this.width=650; src= http://s3.51cto.com/wyfs02/M01/75/81/ Wkiom1y60bgdznqbaamdaun_pp4519.jpg "title=" 9.png "alt=" Wkiom1y60bgdznqbaamdaun_pp4519.jpg "/>
The front-end configuration is complete to prevent local Email impact, you can disable and only leave our custom external mailboxes.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/75/7E/wKioL1Y60F7zOMcBAAIBSE6keZY834.jpg "title=" 10.png "alt=" Wkiol1y60f7zomcbaaibse6kezy834.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/75/81/wKiom1Y60DCDd2cPAAPa0RC7dTk448.jpg "title=" 11.png "alt=" Wkiom1y60dcdd2cpaapa0rc7dtk448.jpg "/>
If the configuration is normal, then you can use the external mailbox to send mail, you can turn off a zabbix_agentd test, see if it will trigger the alarm, send you an email. I wish you success!
This article is from the "Li Zhenliang Technology Blog" blog, make sure to keep this source http://lizhenliang.blog.51cto.com/7876557/1709933
Zabbix sending mail alerts using an external mailbox server