zabbix uses 163 mailbox to alarm

1) Create a host, create item and trigger for it. Demonstrated here is a direct link to the template
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
2) Add alarm media type to the user
Insert picture description here
Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here
3) Configure /etc/mail.rc, add the following lines at the end

set sendcharsets=iso-8859-1,utf-8
set from=MAIL [email protected]
set smtp=smtp.163.com       
set smtp-auth-user=MAIL [email protected]
set smtp-auth-password=PASSWORD
set smtp-auth=login

4) Test sending email

echo "hello world" | mail -s "zabbix" MAIL [email protected]

Insert picture description here
5) Define the action for the trigger
Insert picture description here
Insert picture description here
Insert picture description here
6) Test if the httpd of the agent port is stopped, and whether it will send an email
Insert picture description here
7) Email alarm information

Insert picture description here

If the sent email is an attachment, you can
install the dos2unixconversion tool as follows: 1) Install the conversion tool (to solve the problem that the sent email is in the attachment format)

 yum install -y dos2unix

2) Create a script to send mail

[root@zabbix ~]# cat sendmail.sh 
#!/bin/bash 
#export.UTF-8 ###解决发送的中文变成了乱码的问题 
FILE=/tmp/mailtmp.txt 
echo "$3" >$FILE 
dos2unix -k $FILE ###解决了发送的邮件内容变成附件的问题。 
/bin/mail -s "$2" $1 < $FILE

mv sendmail.sh /usr/lib/zabbix/alertscripts/   # 此处为zabbix-server.conf中定义的目录。

3) Modify the above alarm media type
Insert picture description here
4) The rest of the definitions are the same as the above, stop httpd on the agent port, and test email sending
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_44564366/article/details/111829610