1. Add monitoring Linux host1. Configuration-Host-Create Host 2. Fill in the information 3. Add template 4. Check the status 2. Configure the mailboxSystem environment: [root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) 1. Install the mail sending tool mailx If you have installed other email sending tools, close them first. service sendmail stop ##Close sendmail systemctl disable sendmail.service ##Disable sendingmail at boot service postfix stop ##Shut down postfix systemctl disable postfix.service ##Disable postfix startup [root@localhost ~]# yum install mailx 2. Configure the Zabbix server external mailbox, open the file vim /etc/mail.rc. If the mail.rc file does not exist, create it manually and add the following content: [root@localhost ~]# vim /etc/mail.rc set sendcharsets=iso-8859-1,utf-8 set [email protected] set smtp=smtp.163.com #163 mailbox needs to open smtp authorization set [email protected] #Authentication user set smtp-auth-password=xxx #Authentication password 3. Test email sending [root@localhost ~]# echo "zabbix test mail" | mail -s "zabbix" [email protected] 4. Write a script to send emails 1) Install the dos2unix conversion tool (to solve the problem that the emails sent are in the xx.bin attachment format), (the directory name will change in 7.5.1804) If the download link here is invalid, go to Alibaba'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%] The following email is displayed, but the text cannot be displayed 2) Modify the content of the email sending script Why do we create this script under this path? This is configured in our zabbix_serber.conf file So if you don't want to put the script in this directory, you need to modify the value of AlertScriptsPath in the server configuration file. [root@localhost ~]# vim /usr/lib/zabbix/alertscripts/sendmail.sh #!/bin/bash #export.UTF-8 #Solve the problem that the sent Chinese characters become garbled characters FILE=/tmp/mailtmp.txt echo "$3" >$FILE dos2unix -k $FILE #Solved the problem of the content of the sent email becoming an attachment. /bin/mail -s "$2" $1 < $FILE 3) Create a temporary file and authorize it. Make sure your user exists in zabbix [root@localhost ~]# touch /tmp/mailtmp.txt [root@localhost ~]# chown zabbix.zabbix /tmp/mailtmp.txt 4) The above three parameters are used to receive information passed from the web page: $1: recipient’s email address; 5) Add permissions to the script, otherwise the email cannot be sent normally when an alarm occurs [root@localhost ~]# chmod 755 /usr/lib/zabbix/alertscripts/sendmail.sh 5. Management - Alarm Media Type - Create Media Type 6. Fill in the content Add the following three parameters, corresponding to the three parameters required by the sendmail.sh script: recipient address, subject, and detailed content {ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE} If you do not add these three parameters in 3.0, an error will be reported, because after 3.0, zabbix allows custom parameters, so the parameters will not be passed by default. In 2.0, three parameters will be passed by default, so if you do not write these three parameters in 3.0, an error will be reported. 7. Add alarm media to users 8. Set alarm conditions: Configure-Action-Create Action 1) Set the conditions and name 2) Fill in the recipient, the default information, the user is the recipient just filled in, MyEmail is also just created Fault alarm:{TRIGGER.STATUS}:{TRIGGER.NAME} Explanation: The default step is 1-1, which means starting from 1 and ending at 1. Once a failure occurs, the sendEmail.sh script is executed to send an alarm email to the Admin user and the zabbix administrator group. If the failure lasts for 1 hour, it will only be sent once. If it is changed to 1-0, 0 means no limit. The infinite sending interval is the default duration of 60 seconds. So in one hour, 60 emails will be sent. 3) Recovery operation Fault resolved:{TRIGGER.STATUS}: {TRIGGER.NAME}
9. Test email alert 1) Turn on the trigger 2) You can change the critical value of the trigger in the monitoring of available memory in the template that comes with Zabbix to greater than 20 and enter the template list After the change 3) Modify the update time to make it faster to detect 4) View alarms 5) Email confirmation If there is a problem sending emails, restart the server, zabbix-server and httpd services, and restart the zabbix-agent service on the client. You may also be interested in:
|
<<: MySQL InnoDB MRR Optimization Guide
>>: Vue implements a scroll bar style
This article shares the installation and configur...
If you want to hide content from users of phones, ...
1. To optimize the query, try to avoid full table...
First, let’s take a look at a CSS carousel animat...
Table of contents background analyze method backg...
Table of contents Phenomenon: Port usage: Spellin...
Today we discussed the issue of what the margin v...
mysqldump tool backup Back up the entire database...
Table of contents Preface 1. Parent component pas...
Unzip the file into a directory This is the direc...
Recently, the Vue project needs to refresh the da...
Article Structure 1. Preparation 2. Install Java ...
Table of contents What is a headless browser? Why...
By default, PHP on CentOS 7 runs as apache or nob...
Table of contents 1. Pre-analysis 1. Variable pre...