Environment Description:
Environment |
IP |
Server-side |
192.168.209.12 |
Client |
192.168.209.13 |
Experimental conditions:
Zabbix monitoring Server, the client has been deployed to complete, the monitored host has been added to complete, Zabbix monitoring operation is normal.
Purpose of implementation:
Zabbix Monitoring Server Set up the mail alarm, when the monitored host is down or reached the trigger preset value, will automatically send an alarm message to the designated mailbox.
operation on the server 1. Install the Mail sending tool mailx[[email protected] ~]# yum-y install MAILX 2. Configure mail[[email protected] ~]# Vim/etc/mail . rcset [email protected]///For Zabbi server forwarding mail to the specified mailbox set smtp=smtp.163.com//Send mailbox servers address Smtpset [email protected]/ /mailbox User set smtp-auth-password=lzy999999//Authorization Code password set smtp-auth=login//Login//Start mail mail Service [[email protected] ~]# Syst Emctl restart postfix3. Test mail can be sent [[email protected] ~]# echo "Host" | Mail-s ' primary ' [email protected] Zabbix server Set up mailbox Alarm 4. Write a mail send script (on server side) [[email protected] ~]# cd/usr/local/share/za bbix/alertscripts/[[email protected] alertscripts]# vim mail.sh #!/bin/bashmessages= ' echo $ | Tr ' \ r \ n ' \ n ' subject= ' echo | Tr ' \ r \ n ' \ n ' echo ' ${messages} ' | Mail-s "${subject}" >>/tmp/sendmail.log 2>&1//modify the generic group of the script directory [[email protected] alertscripts]# Chown zabbix.zabbix/usr/local/share/zabbix/alertscripts///give script execution permissions [[email protected] alertscripts]# chmod +x/ Usr/local/share/zabbix/alertscripts/mail.sH[[email protected] alertscripts]# ll zabbix.zabbix/usr/local/share/zabbix/alertscripts/-rwxr-xr-x 1 Zabbix Zabbix 153 15:02 mail.sh[[email protected] alertscripts]# ll zabbix.zabbix/usr/local/share/zabbix/ Alertscripts/mail.sh-rwxr-xr-x 1 Zabbix Zabbix 153 15:02/usr/local/share/zabbix/alertscripts/mail.sh// Create a directory where the script holds the log and modify the genus Group [[email protected] ~]# touch/tmp/sendmail.log [[email protected] ~]# chown Zabbix.zabbix /tmp/sendmail.log[[email protected] ~]# ll/tmp/sendmail.log-rw-r--r--1 Zabbix Zabbix 2082-15:14/TMP/SENDMA Il.log5. Edit Zabbix_server.conf profile [[email protected] ~] #vim/usr/local/etc/zabbix_server.conf # # #Option: Alertscriptspath#full path to location of the custom alert scripts. #Default depends on compilation options. #Mandatory: No#defa Ult: #AlertScriptsPath =${datadir}/zabbix/alertscriptsalertscriptspath=/usr/local/share/zabbix/alertscripts// Change to mail.sh script store path 6. Use a script to perform a mail-sending test [[email protected] alertscripts]#./mail.sh [Email protected] "This is" ll "7.Zabbix background Web Interface configuration 1. Manage----Alarm Media types-----Create media types. 2. Name can be defined-----Type selection script-----Script name Enter the script name of the sent message in the previous step----Add the following 3 parameters, corresponding to the script requires 3 parameters: Recipient address, subject, details: {ALERT. Sendto}{alert. Subject}{alert. MESSAGE}
3. Manage----User-----Select Admin user. (You can create a user yourself)
Zabbix Server Set up mailbox alerts
4. Alarm media----added.
Type Enter the type of alarm media you just created SendMail script---Enter a personal mailbox to receive alarm messages---start tick----Add.
Zabbix Server Set up mailbox alerts
5. Configure----actions----create actions.
Action----Name Customization---enable----Add. (Trigger conditions need to be set according to the actual situation, equivalent to regular expressions, generally not set, equivalent to monitoring all monitoring items)
6. Define the operation.
7.Zabbix Background Web Interface configuration
1. Manage----Alarm Media types-----Create media types.
2. Name can be defined-----Type selection script-----Script name Enter the script name of the sent message that you wrote in the previous step----
Add the following 3 parameters, corresponding to the 3 parameters required by the script: recipient address, subject, detailed content:
{ALERT. SENDTO}
{ALERT. SUBJECT}
{ALERT. MESSAGE}
3. Manage----User-----Select Admin user. (You can create a user yourself)
4.报警媒介 ---- 添加。
Type Enter the type of alarm media you just created SendMail script---Enter a personal mailbox to receive alarm messages---start tick----Add.
5. Configure----actions----create actions.
Action----Name Customization---enable----Add. (Trigger conditions need to be set according to the actual situation, equivalent to regular expressions, generally not set, equivalent to monitoring all monitoring items)
6. Define the operation.
测试
On client operations
The client modifies the monitoring item to see if an alert message is triggered to be sent to the receiver.
I'm here to edit/etc/linfan
[Email protected] ~]# ZABBIX_AGENTD
[Email protected] ~]# echo "Doudou" >>/etc/linfan
Experimental summary
As shown: when the monitored host is down or the trigger preset is reached, an alert message is automatically sent to the specified mailbox.
Zabbix Monitoring Service Set up mailbox notifications in Linux