Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Zabbix3.4 Mail alarm configuration in Centos7

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you the example analysis of Zabbix3.4 email alarm configuration in Centos7. I hope you will get something after reading this article. Let's discuss it together.

1. Add monitoring Linux hosts

1. Configure-host-create host

2. Fill in the information

3. Add a template

4. Check the status

Second, configure mailboxes

System environment:

[root@localhost ~] # cat / etc/redhat-release CentOS Linux release 7.2.1511 (Core)

1. Install the mail sending tool mailx

If other mail sending tools are installed, close the

Service sendmail stop # # shut down sendmailsystemctl disable sendmail.service # # disable boot sendmailservice postfix stop # # shut down postfixsystemctl disable postfix.service # # disable boot postfix [root @ localhost ~] # yum install mailx

2. Configure the Zabbix server external mailbox and open the file vim / etc/mail.rc. If the mail.rc file is not available, create it manually, and then add the following:

[root@localhost ~] # vim / etc/mail.rc

Set sendcharsets=iso-8859-1 UTFMAE 8set from=xxx@163.comset smtp=smtp.163.com # 163Mailbox needs to open smtp authorization set smtp-auth-user=xxx@163.com # authentication user set smtp-auth-password=xxx # authentication password

3. Test email delivery

[root@localhost ~] # echo "zabbix test mail" | mail-s "zabbix" xxx@163.com

4. Write a script to send mail

1) install dos2unix conversion tool (solve the problem that the email sent is in the format of xx.bin attachment), (the directory name of 7.5.1804 will be changed) if the download link here fails, go to Ali's official website to find the corresponding file.

[root@localhost ~] # rpm-ivh https://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/Packages/dos2unix-6.0.3-7.el7.x86_64.rpm

Get https://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/Packages/dos2unix-6.0.3-7.el7.x86_64.rpm

Preparing. # # [100%]

Upgrading / installing...

1:dos2unix-6.0.3-7.el7 # # [100%]

Accept the email below, but the text cannot be displayed

2) modify the content of the email sending script

Why did we create this script under this path, which is configured in our zabbix_serber.conf file

AlertScriptsPath=/usr/lib/zabbix/alertscripts

So you don't want to put this script in this directory, you need to modify the value of AlertScriptsPath in the server's configuration file.

[root@localhost ~] # vim / usr export.UTF-8 export.UTF-8 # solve the problem that the Chinese sent becomes garbled FILE=/tmp/mailtmp.txt echo "$3" > $FILE dos2unix-k $FILE # solves the problem that the content of the message sent becomes an attachment. / bin/mail-s "$2" $1

< $FILE 3)创建临时文件并授权,这里确保你的用户存在zabbix [root@localhost ~]# touch /tmp/mailtmp.txt[root@localhost ~]# chown zabbix.zabbix /tmp/mailtmp.txt 4)上面的这三个参数是接收从Web页面传递的信息: $1:收件人邮箱地址; $2:邮件标题; $3:邮件内容 5)给脚本添加权限,要不发生告警的时候邮件无法正常发送出去 [root@localhost ~]# chmod 755 /usr/lib/zabbix/alertscripts/sendmail.sh 5、管理-报警媒介类型-创建媒体类型 6、填写内容 添加以下3个参数,分别对应sendmail.sh脚本需要的3个参数:收件人地址、主题、详细内容 {ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE} 如果在3.0中不添加这三个参数会报错,因为在3.0以后zabbix允许自定义参数了,所以不会默认传递参数,在2.0的时候会默认传递三个参数,所以在3.0如果不写这三个参数会报错。 7、给用户添加报警媒介

8. Set alarm conditions: configure-Action-create Action

1) set conditions and names

2) enter the recipient (default information). The user is the recipient who has just been filled in, and the MyEmail is also newly created.

Fault alarm: {TRIGGER.STATUS}: {TRIGGER.NAME}

Alarm host: {HOST.NAME}

Host address: {HOST.IP}

Alarm time: {EVENT.DATE} {EVENT.TIME}

Alarm level: {TRIGGER.SEVERITY}

Alarm message: {TRIGGER.NAME}

Question details: {ITEM.NAME}: {ITEM.VALUE}

Event code: {EVENT.ID}

Explanation: the default step is 1-1, that is, from 1 to 1. Once the failure occurs, the sendEmail.sh script is executed to send an alarm email to the Admin user and the zabbix administrator group. If the fault lasts for 1 hour, it will only be sent once. If you change it to 1-0, it means there is no limit. The infinite send interval is the default duration of 60 seconds. Then 60 emails will be sent in an hour.

3) restore operation

Troubleshooting: {TRIGGER.STATUS}: {TRIGGER.NAME}

Recovery host: {HOST.NAME}

Host address: {HOST.IP}

Recovery time: {EVENT.DATE} {EVENT.TIME}

Recovery level: {TRIGGER.SEVERITY}

Recovery information: {TRIGGER.NAME}

Question details: {ITEM.NAME}: {ITEM.VALUE}

Event code: {EVENT.ID}

At this point, our email alarm configuration is complete, as long as the trigger we set triggers, it will automatically send me an alarm email.

9. Test email alarm

1) Open the trigger

2) you can change the critical value of the trigger in the monitoring of available memory in the template included with zabbix to greater than 20 to enter the template list.

After the change

3) modify the update time to make it detect faster

4) check the alarm

5) email confirmation

If there is a problem with sending email, restart the server and the zabbix-server and httpd services, and the client restart the zabbix-agent service.

After reading this article, I believe you have some understanding of "sample Analysis of Zabbix3.4 email alarm configuration in Centos7". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report