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

How to configure zabbix to achieve email warning effect?

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

Share

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

The email warning method implemented here is to use a mailbox account that can send and receive email normally on the Internet (for example: * * @ 163.com). By setting it in the zabbix server, you can send an alarm email to the specified mailbox in case of failure.

Implementation steps:

1. Install the mail sending tool mailx

If the version information can be found, the installation is successful.

2. Modify the configuration file

Add the following at the end of the / etc/mail.rc file and restart the zabbix-server service:

How to obtain Smtp-auth-passwordd is shown in the following figure:

3. Modify the web end

The three script parameters correspond to the required parameters in the sendmail.sh script: recipient address, subject, and details.

Configure users. Take Admin as an example. Since Admin users are in the Zabbix administrators user group, make sure that this group has administrative permissions for all CVM groups:

Configure actions to associate alerts with e-mail actions

Modify the alarm content:

Default title:

{TRIGGER.STATUS}: {TRIGGER.NAME}

Message content:

Failure: {TRIGGER.STATUS}, server: {HOSTNAME1} occurred: {TRIGGER.NAME} failure! Alarm host: {HOSTNAME1}, IP address: {HOST.CONN} alarm time: {EVENT.DATE}-{EVENT.TIME} alarm level: {TRIGGER.SEVERITY} alarm message: {TRIGGER.NAME} alarm item: {TRIGGER.KEY1} problem details: {ITEM.NAME}: {ITEM.VALUE} current status: {TRIGGER.STATUS}: {ITEM.VALUE1} event ID: {EVENT.ID}

The content of alarm recovery is also modified:

Default title: {TRIGGER.STATUS}: {TRIGGER.NAME} message content: restore: {TRIGGER.STATUS}, server: {TRIGGER.NAME} has been restored! Alarm host: {HOSTNAME1}, IP address: {HOST.CONN} alarm time: {EVENT.DATE}-- {EVENT.TIME} recovery time: {EVENT.DATE}-- {EVENT.RECOVERY.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 operation settings are the same

Note: step 1-3: the default is 1-1, that is, from 1 to 1. Once the failure occurs, execute the sendmail.sh script to send an alarm email to the user group or users you set (I only added Admin users above). If the fault is not solved for an hour, it will only be executed once. If 1-0 means unlimited times, the sending interval is 60s of the step duration. 60 emails will be sent, which is obviously unreasonable.

Web end configuration is complete

4. Write sendmail.sh script

Notice the storage path of the alarm script that you set in the configuration file of zabbix-server:

I chose the default here and did not change it, so the sendmail.sh script must be placed under this path

The content of the script is as follows (remember + X permission):

#! / bin/shexport.UTF-8FILE=/tmp/mailtmp.txtecho "$3" > $FILEdos2unix-k $FILE/bin/mail-s "$2" $1 < $FILEtouch / tmp/mailtmp.txtchown zabbix.zabbix / tmp/mailtmp.txt

5. Verification test

Stop zabbix-agent on zabbix server to see if you can receive an alarm email.

Recover messages:

Zabbix email warning completed

Ending.

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: 293

*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