Linux-Zabbix email alert settings, linux-zabbix alert
System Environment: Ubuntu 16.04 on Zabbix Server
Install sendmail
sudo apt install sendmail
Test email sending
Echo "text! "| Mail-s title XXX@qq.com
After successful installation, continue to install the email server. Heirloom-mailx in Ubuntu
Apt-get install heirloom-mailx
# The yum install mailx // CentOS is mailx. After CentOS is installed, you need to change the configuration file. For details, see
After installation, configure the. sh sending script.
Mkdir/etc/zabbix/alertscripts vim/etc/zabbix/zabbix_server.conf // modify alert scripts to the following path: AlertScriptsPath =/etc/zabbix/alertscripts/etc/init. d/zabbix_server restart // restart zabbix server # vim/etc/zabbix/alertscripts/sendmail. sh // write the mail sending script messages = 'echo $3 | tr' \ r \ n' subject = 'echo $2 | tr' \ r \ N' '\ n' echo "$ {messages}" | mail-s "$ {subject}" $1>/tmp/sendmail. log 2> & 1
Add executable permissions
chown zabbix.zabbix /etc/zabbix/alertscripts/sendmail.shchmod +x /etc/zabbix/alertscripts/sendmail.sh
Test script
Su-zabbix/etc/zabbix/alertscripts/sendmail. sh xxxx@qq.com "test mail title" "test mail content" // check whether calls can be performed by zabbix users
Next, configure the web server.
1. Configure --- enable the action. In this step, you can edit the content and format of the sent email.
2. Manage --- alarm media type-create media type, for example:
Add three script parameters:
{ALERT. SENDTO}, {ALERT. SUBJECT}, {ALERT. MESSAGE}
The three parameters correspond to the three parameters required by the sendEmail. sh Script: Recipient address, topic, and details.
3. Set the email address for receiving alerts-enable
Whether the test is successful. Enter
/etc/init.d/zabbix_agentd stop
Check whether an alarm email is received normally! Complete.