Zabbix monitoring Server, the client has been deployed to complete, the monitoring host has been added, Zabiix monitoring operation is normal.
Set up mail alerts on the Zabbix server and automatically send alert messages to designated mailboxes when the monitored host is down or when the trigger defaults are reached.
The following operations are performed on the Zabbix monitoring server
Note: Zabbix monitoring service side
Host Name: zabbix.osyunwei.com
There are two types of email alerts:
1, Zabbix server is simply sent to the alarm mail to the designated mailbox, send the alarm mail account is the Zabbix service side of the local mailbox account (for example: root@localhost.localdomain), can only send, can not receive external mail.
2, the use of a normal Internet mail to send and receive e-mail accounts (such as: xxx@163.com), through the Zabbix server set up to enable it to send alarm messages to the designated mailbox.
First: Send mail using Zabbix service-side Local mailbox account
First, install SendMail or postfix
Service SendMail Start #启动
Chkconfig SendMail on #设置开机启动
CentOS 5.x is installed by default SendMail
CentOS 6.x is installed by default Postfix
SendMail and postfix only need to install one and open the service.
Second, the installation of mail delivery tool MAILX
CentOS 5.x Compiler installation MAILX, direct yum installed MAILX version is too old to use external mail to send a problem.
Yum Remove Mailx #卸载系统自带的旧版mailx
http://nchc.dl.sourceforge.net/project/heirloom/heirloom-mailx/12.4/mailx-12.4.tar.bz2
Tar jxvf mailx-12.4.tar.bz2 #解压
Make install Ucbinstall=/usr/bin/install #安装
Ln-s/usr/local/bin/mailx/bin/mail #创建 mailx to mail soft connections
Ln-s/etc/nail.rc/etc/mail.rc #创建mailx配置文件软连接
echo "Zabbix test Mail" |mail-s "Zabbix" xxx@163.com
#测试发送邮件, title Zabbix, mail content: Zabbix test mail, sent to the mailbox: xxx@163.com
Third, configure Zabbix service-side mail alarm
System Yun-wei warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
Management-Warning Media type-email
SMTP server: zabbix.sa.huanqiu.com
SMTP HELO:zabbix.sa.huanqiu.com
SMTP Email: zabbix@zabbix.sa.huanqiu.com
Note: zabbix.sa.huanqiu.com is the Zabbix Monitor end host name, recommended to modify, otherwise use the default localhost.localdomain send mail will be used as spam interception.
2, set Zabbix user alarm email address
Configuration-User-admin (Zabbix Administrator)
Switch to the warning medium
System Yun-wei warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
Other defaults can also be set as needed
3, set Zabbix trigger the alarm action
Configuration-action-Create action
Default recipient: Fault {TRIGGER. STATUS}, server: {HOSTNAME1} occurred: {Trigger.name} failure!
Alarm time: {EVENT. DATE} {EVENT. TIME}
Alarm level: {TRIGGER. SEVERITY}
Warning message: {trigger.name}
Alarm item: {TRIGGER. KEY1}
Question details: {Item.name}:{item. VALUE}
Current state: {TRIGGER. Status}:{item. VALUE1}
Recovery information: Tick
Recovery theme: Restore {TRIGGER. STATUS}, server: {HOSTNAME1}: {trigger.name} has been restored!
Alarm time: {EVENT. DATE} {EVENT. TIME}
Alarm level: {TRIGGER. SEVERITY}
Warning message: {trigger.name}
Alarm item: {TRIGGER. KEY1}
Question details: {Item.name}:{item. VALUE}
Current state: {TRIGGER. Status}:{item. VALUE1}
Operation type: send out information
Default information: Tick
Turn off the Zabbix client service
Service Zabbix_agentd Stop
Check the xxx@163.com mailbox and receive an alert message
Open Zabbix Client Service again
Service Zabbix_agentd Start
To view the xxx@163.com mailbox, you will receive a recovery message
Use the Zabbix service-side local mailbox account to send the message setup complete.
The second type: Use the external email account to send the alarm message settings
One, close sendmail or postfix
Service SendMail Stop #关闭
Chkconfig SendMail off #禁止开机启动
When using an external email account, you do not need to start SendMail or postfix
If an alert message is sent using an external mailbox while sendmail or Postfix is started, the external mailbox is first read
Configuration information.
Second, the installation of mail delivery tool MAILX
CentOS 5.x Compiler installation MAILX, direct yum installed MAILX version is too old to use external mail to send a problem.
Yum Remove Mailx #卸载系统自带的旧版mailx
http://nchc.dl.sourceforge.net/project/heirloom/heirloom-mailx/12.4/mailx-12.4.tar.bz2
Tar jxvf mailx-12.4.tar.bz2 #解压
Make install Ucbinstall=/usr/bin/install #安装
Ln-s/usr/local/bin/mailx/bin/mail #创建mailx到mail的软连接
Ln-s/etc/nail.rc/etc/mail.rc #创建mailx配置文件软连接
Third, configure Zabbix service-side external mailboxes
Vi/etc/mail.rc #编辑, add the following information
Set from=xxx@163.com smtp=smtp.163.com
Set smtp-auth-user=xxx@163.com smtp-auth-password=123456
echo "Zabbix test Mail" |mail-s "Zabbix" yyy@163.com
#测试发送邮件, title Zabbix, mail content: Zabbix test mail, sent to the mailbox: yyy@163.com
#这时候, the mailbox yyy@163.com will receive a test message from xxx@163.com
Iv. Configure Zabbix service-side mail alerts
Management-Warning Media type-Create media type
2, set Zabbix user alarm email address
Configuration-User-admin (Zabbix Administrator)
Switch to warning media-add
Other defaults can also be
3, set Zabbix trigger the alarm action
Configuration-action-Create action
Default recipient: Fault {TRIGGER. STATUS}, server: {HOSTNAME1} occurred: {Trigger.name} failure!
Alarm time: {EVENT. DATE} {EVENT. TIME}
Alarm level: {TRIGGER. SEVERITY}
Warning message: {trigger.name}
Alarm item: {TRIGGER. KEY1}
Question details: {Item.name}:{item. VALUE}
Current state: {TRIGGER. Status}:{item. VALUE1}
Recovery information: Tick
Recovery theme: Restore {TRIGGER. STATUS}, server: {HOSTNAME1}: {trigger.name} has been restored!
Alarm time: {EVENT. DATE} {EVENT. TIME}
Alarm level: {TRIGGER. SEVERITY}
Warning message: {trigger.name}
Alarm item: {TRIGGER. KEY1}
Question details: {Item.name}:{item. VALUE}
Current state: {TRIGGER. Status}:{item. VALUE1}
Operation type: send out information
Default information: Tick
4, add Zabbix service-side mail Send script
Cd/usr/local/zabbix/share/zabbix/alertscripts #进入脚本存放目录
VI sendmail.sh #编辑, add the following code
Chown zabbix.zabbix/usr/local/zabbix/share/zabbix/alertscripts/sendmail.sh
chmod +x/usr/local/zabbix/share/zabbix/alertscripts/sendmail.sh
Turn off the Zabbix client service
Service Zabbix_agentd Stop
Check the xxx@163.com mailbox and receive an alert message
Open Zabbix Client Service again
Service Zabbix_agentd Start
To view the xxx@163.com mailbox, you will receive a recovery message
Use the external email account to send the alert message setup complete.
At this point, the Zabbix message alert settings are complete.