zabbix4.0 configuration procedure detailed alarm messages (FIG band)

1, install mail

[root@zabbix alertscripts]# yum install mailx -y

2, edit the configuration file to add the last line

[root@zabbix alertscripts]# vim /etc/mail.rc
set bsdcompat
set sendcharsets=iso-8859-1,utf-8
set from=邮箱
set smtp=smtp://smtp.exmail.qq.com
set smtp-auth-user=邮箱
set smtp-auth-password=邮箱密码
set smtp-auth=login

3, send a test message is normal

[root@zabbix alertscripts]# echo "zabbix test mail" |mail -s "zabbix" 邮箱

4, write e-mail 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 the 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, the test script to send mail

[Root @ zabbix alertscripts] # ​​echo "hello world" | mail -s "testmail" Your mailbox

7, zabbix configuration web page
zabbix4.0 configuration procedure detailed alarm messages (FIG band)
to add a script three parameters
{ALERT.SENDTO}
{ALERT.SUBJECT}
{} ALERT.MESSAGE
zabbix4.0 configuration procedure detailed alarm messages (FIG band)
. 8, user configuration
zabbix4.0 configuration procedure detailed alarm messages (FIG band)
zabbix4.0 configuration procedure detailed alarm messages (FIG band)
zabbix4.0 configuration procedure detailed alarm messages (FIG band)
9, the operation of the configuration
zabbix4.0 configuration procedure detailed alarm messages (FIG band)
zabbix4.0 configuration procedure detailed alarm messages (FIG band)
failure {TRIGGER.STATUS}, the server name: {HOSTNAME1} occur: { TRIGGER.NAME} fault!

Alarm Host: {HOSTNAME}
trap host IP address: {HOST.IP}
alert time: {EVENT.DATE} {EVENT.TIME}
Alarm Level: {TRIGGER.SEVERITY}
alarm information: {TRIGGER.NAME}
Alarm items: {TRIGGER .KEY1}
issue details: {iTEM.NAME}: {ITEM.VALUE}
current status: {TRIGGER.STATUS}: {ITEM.VALUE1}
event ID: {EVENT.ID}
zabbix4.0 configuration procedure detailed alarm messages (FIG band)
zabbix4.0 configuration procedure detailed alarm messages (FIG band)
zabbix4.0 configuration procedure detailed alarm messages (FIG band)
recovery {TRIGGER.STATUS}, server name: { hOSTNAME1}: {TRIGGER.NAME} has been restored!

Alarm Host: {HOSTNAME}
trap host IP address: {HOST.IP}
alert time: {EVENT.DATE} {EVENT.TIME}
Alarm Level: {TRIGGER.SEVERITY}
alarm information: {TRIGGER.NAME}
Alarm items: {TRIGGER .KEY1}
issue details: {iTEM.NAME}: {ITEM.VALUE}
current status: {TRIGGER.STATUS}: {ITEM.VALUE1}
event ID: {} EVENT.ID
zabbix4.0 configuration procedure detailed alarm messages (FIG band)
10, to complete the test
test send message content
zabbix4.0 configuration procedure detailed alarm messages (FIG band)

Guess you like

Origin blog.51cto.com/12226796/2440359