Zabbix4.0 configuration email alarm detailed procedure (with figure)
1. Install mail
[root@zabbix alertscripts] # yum install mailx-y
2. Edit the configuration file and add it on the last line
[root@zabbix alertscripts] # vim / etc/mail.rc
Set bsdcompat
Set sendcharsets=iso-8859-1 UTFMUF 8
Set from= mailbox
Set smtp=smtp://smtp.exmail.qq.com
Set smtp-auth-user= mailbox
Set smtp-auth-password= mailbox password
Set smtp-auth=login
3. Test whether the email is sent normally.
[root@zabbix alertscripts] # echo "zabbix test mail" | mail-s "zabbix" mailbox
4. Write an email script
[root@zabbix alertscripts] # cd / usr/lib/zabbix/alertscripts
[root@zabbix alertscripts] # vi mailx.sh
#! / bin/bash
# send mail
Messages=echo $3 | tr'\ r\ n'\ n'
Subject=echo $2 | tr'\ r\ n'\ n'
Echo "${messages}" | mail-s "${subject}" $1 > > / tmp/mailx.log 2 > & 1
5. Modify permissions
Touch / tmp/mailx.log
Chown-R zabbix.zabbix / tmp/mailx.log
Chmod + x / usr/lib/zabbix/alertscripts/mailx.sh
Chown-R zabbix.zabbix / usr/lib/zabbix/
6. Test script to send email
[root@zabbix alertscripts] # echo "hello world" | mail-s "testmail" your email address
7. Configure web on zabbix page
Add three script parameters
{ALERT.SENDTO}
{ALERT.SUBJECT}
{ALERT.MESSAGE}
8. User configuration
9. Configure actions
Fault {TRIGGER.STATUS}, server name: {HOSTNAME1} occurred: {TRIGGER.NAME} failure!
Alarm host: {HOSTNAME}
Alarm host IP address: {HOST.IP}
Alarm time: {EVENT.DATE} {EVENT.TIME}
Alarm level: {TRIGGER.SEVERITY}
Alarm message: {TRIGGER.NAME}
Alarm item: {TRIGGER.KEY1}
Question details: {ITEM.NAME}: {ITEM.VALUE}
Current status: {TRIGGER.STATUS}: {ITEM.VALUE1}
Event ID: {EVENT.ID}
Restore {TRIGGER.STATUS}, server name: {HOSTNAME1}: {TRIGGER.NAME} has been restored!
Alarm host: {HOSTNAME}
Alarm host IP address: {HOST.IP}
Alarm time: {EVENT.DATE} {EVENT.TIME}
Alarm level: {TRIGGER.SEVERITY}
Alarm message: {TRIGGER.NAME}
Alarm item: {TRIGGER.KEY1}
Question details: {ITEM.NAME}: {ITEM.VALUE}
Current status: {TRIGGER.STATUS}: {ITEM.VALUE1}
Event ID: {EVENT.ID}
10. Complete the test
Test the content of the message sent