Get the App
SLTechnology News&Howtos  ›  Database  › 

Zabbix email alarm-sendmail

Shulou Source: shulou.com Published: 2022-06-01 10:43:17 11月12日 Update

Using several email alarm software, I still feel that sendmail is timely and stable.

1. Configure on the zabbix server server:

1.1 the storage path of the sending mail script:

123 [root@zabbix_server etc] # cat zabbix_server.conf | grep alertscripts # AlertScriptsPath=$ {datadir} / zabbix/alertscripts AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts

1.2 download and installation of sendmail software:

I use SendEmail, if the mail that comes with your system can send a successful email with your own, you can refer to my other article, Centos5.x & Centos6.x uses the mail command to send email and how to forge the sender: http://pynliu.blog.51cto.com/5027391/1608916.

SendEmail download address; http://caspian.dotconf.net/menu/Software/SendEmail/#download

Unzip it and put it in any directory. I put it in the / usr/local/zabbix/share/zabbix/alertscripts directory.

12 [root@zabbix_server alertscripts] # lssendEmail-v1.56

1.3 the alarm message of zabbix will pass three variables, all of which are configured in the zabbix_web interface. They are: recipient email, alarm subject and alarm content, and $1 $2 $3 in the script

Write a script sendmail and give executable permission

12345678 [root@zabbix_server alertscripts] # chmod axix sendmail.sh [root@zabbix_server alertscripts] # cat sendmail.sh #! / bin/bash# $1 sendmail address# $2 sendmail subject# $3 contentSENDMAIL=/usr/local/zabbix/share/zabbix/alertscripts/sendEmail-v1.56/sendEmail$SENDMAIL-f LangFang@zabbix.com-t "$1"-s xxx.benguo.cn-u "$2"-m "$3" > > / dev/null

Note: LangFang@zabbix is the sender's mailbox, is a fake sender, can be self-defined as long as it is not identified as a spam mailbox.

Explanation:

-f indicates the sender's mailbox

-t indicates the recipient's mailbox

(to receive and send mail, try not to use the same mailbox account, it is easy to make mistakes)

-s represents the domain name or ip of the SMTP server

-u indicates the subject of the message

-xu represents the user name authenticated by SMTP

-xp represents the password authenticated by SMTP (note that this password seems to be limited, for example, if I use dumb5neyland, it cannot be correctly identified)

-m represents the content of the message

2. The following is the configuration on zabbix web:

2.1 configure "alarm Media Type" to create a media type:

Make sure that the name of the script is the same as that written on the server.

2.2 user Settings:

The warning degree is the severity of the trigger.

Third, create actions

Fourth, after adding, the alarm will be realized according to the trigger.

Tags: Mail alarm mailbox script configuration sender server service subject content password user directory type trigger software authentication success three severity Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Redmi Xiaomi macOS MySQL