Linux Zabbix mail Alert settings configuration steps

Source: Internet
Author: User
Tags auth bz2 email account mail account
Description
Zabbix monitoring Server, the client has been deployed to complete, the monitoring host has been added, Zabiix monitoring operation is normal.
To achieve the purpose:
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.
Specific actions:
The following operations are performed on the Zabbix monitoring server
Note: Zabbix monitoring service side
Operating system: CentOS
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
Yum Install SendMail #安装
Service SendMail Start #启动
Chkconfig SendMail on #设置开机启动
Yum install Postfix
Service Postfix start
Chkconfig Postfix 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
Yum Install 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
Download MAILX:
http://nchc.dl.sourceforge.net/project/heirloom/heirloom-mailx/12.4/mailx-12.4.tar.bz2
Tar jxvf mailx-12.4.tar.bz2 #解压
CD mailx-12.4 #进入目录
Make #编译
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配置文件软连接
Whereis Mailx #查看安装路径
Mailx-v #查看版本信息
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
1, open Zabbix
System Yun-wei warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
Management-Warning Media type-email
Name: Email
Type: E-mail
SMTP server: zabbix.sa.huanqiu.com
SMTP HELO:zabbix.sa.huanqiu.com
SMTP Email: zabbix@zabbix.sa.huanqiu.com
Already used: tick
Archive
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
Add to
System Yun-wei warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
Type: Email
Recipient: xxx@163.com
Other defaults can also be set as needed
Status: Enabled
Archive
3, set Zabbix trigger the alarm action
Configuration-action-Create action
Name: Action-email
Default recipient: Fault {TRIGGER. STATUS}, server: {HOSTNAME1} occurred: {Trigger.name} failure!
Default information:
Alarm host: {HOSTNAME1}
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}
Event Id:{event.id}
Recovery information: Tick
Recovery theme: Restore {TRIGGER. STATUS}, server: {HOSTNAME1}: {trigger.name} has been restored!
Recovery information:
Alarm host: {HOSTNAME1}
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}
Event Id:{event.id}
Enabled: Hook
Switch to Action options
of the new
Operation type: send out information
Send to User: add
Default information: Tick
User: Checked admin
Choose
Send only to: Email
Archive
Four, test Zabbix alarm
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 #禁止开机启动
Service Postfix Stop
chkconfig postfix off
Note:
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
Yum Install 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
Download MAILX:
http://nchc.dl.sourceforge.net/project/heirloom/heirloom-mailx/12.4/mailx-12.4.tar.bz2
Tar jxvf mailx-12.4.tar.bz2 #解压
CD mailx-12.4 #进入目录
Make #编译
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配置文件软连接
Whereis Mailx #查看安装路径
Mailx-v #查看版本信息
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
Set Smtp-auth=login
: wq! #保存退出
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
1, open Zabbix
Management-Warning Media type-Create media type
Name: Sendmail
Type: Script
Script Name: sendmail.sh
Enabled: Tick
Archive
2, set Zabbix user alarm email address
Configuration-User-admin (Zabbix Administrator)
Switch to warning media-add
Type: Sendmail
Recipient: xxx@163.com
Other defaults can also be
To set on demand
Status: Enabled
Archive
3, set Zabbix trigger the alarm action
Configuration-action-Create action
Name: Action-email
Default recipient: Fault {TRIGGER. STATUS}, server: {HOSTNAME1} occurred: {Trigger.name} failure!
Default information:
Alarm host: {HOSTNAME1}
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}
Event Id:{event.id}
Recovery information: Tick
Recovery theme: Restore {TRIGGER. STATUS}, server: {HOSTNAME1}: {trigger.name} has been restored!
Recovery information:
Alarm host: {HOSTNAME1}
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}
Event Id:{event.id}
Enabled: Hook
Switch to Action options
of the new
Operation type: send out information
Send to User: add
Default information: Tick
Select User: Admin
Choose
Send only to: Sendmail
Archive
4, add Zabbix service-side mail Send script
Cd/usr/local/zabbix/share/zabbix/alertscripts #进入脚本存放目录
VI sendmail.sh #编辑, add the following code
#!/bin/sh
echo "$" | Mail-s "$" $
: wq! #保存退出
Chown zabbix.zabbix/usr/local/zabbix/share/zabbix/alertscripts/sendmail.sh
#设置脚本所有者为zabbix用户
chmod +x/usr/local/zabbix/share/zabbix/alertscripts/sendmail.sh
#设置脚本执行权限
Five, Test Zabbix alarm
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.