Configure zabbix to send email alerts, and zabbix to send email alerts

Source: Internet
Author: User

Configure zabbix to send email alerts, and zabbix to send email alerts

Overview

This article describes how to configure zabbix to send an email alarm using external mail. zabbix calls mailx through the configuration file to send emails. Mailx is installed by default in Centos6 or later versions.

 

1. Configure mailx

1. Check whether mailx is installed in the current system.

[root@localhost ~]# yum list installed mailxLoaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: ftp.cuhk.edu.hk * extras: mirrors.163.com * updates: mirrors.163.comInstalled Packagesmailx.x86_64                                                                           12.4-8.el6_6                                    

We can see that mailx 12.4 has been installed in my system.

2. Set 163 mailbox client Authorization

Log on to the 163 mailbox and choose "set"> "client Authorization password"> "enable ".

You are required to enter an authorized logon password. This password is required for configuring mailx in the next step.

3. Configure mailx

Vim/etc/mail. rc

set from=cmh@163.com smtp=smtp.163.comset smtp-auth-user=cmh@163.com smtp-auth-password=cmhset smtp-auth=login

Here I use 163 mailbox to send mail, cmh@163.com is the login user of 163 mailbox, smtp-auth-password is the password set in step 2.

4. Test whether emails can be sent normally.

echo "agent down" |mail -s "test mail" 123xxxxxxx@qq.com

2. Configure zabbix

1. Configure the SendMail mail sending script

mkdir  /etc/zabbix/alertscriptscd /etc/zabbix/alertscriptsvim sendmail
messages=`echo $3 | tr '\r\n' '\n'`subject=`echo $2 | tr '\r\n' '\n'`echo "${messages}" | mail -s "${subject}" $1 >>/tmp/sendmail.log 2>&1

Grant the script executable permission

chown -R zabbix:zabbix /etc/zabbix/alertscriptschmod u+x sendmail.sh

2. Configure zabbix_server.conf

Add zabbix_server.conf

AlertScriptsPath=/etc/zabbix/alertscripts

3. Create media types

Note: Select Script for the type. The Script name must be the same as the name of the email sending Script created earlier.

4. Configure the email sending user

In the user options, click the admin user in the Zabbix administrators Group and create the right-click receiver and corresponding security level in the user's media attributes.

The type option here is the name of the media type just created, and send to is the mail recipient.

5. Create a trigger action

Perform operations after configuration-actions is created and triggered

 

Default subject: fault !!! [{HOSTNAME1}]: {TRIGGER. NAME} recovery subject: Recovered !!! [{HOSTNAME1}]: {TRIGGER. NAME} default message and recovery message are both the same: Alert HOST: {HOSTNAME1} alert time: {EVENT. DATE} {EVENT. TIME} alert level: {TRIGGER. SEVERITY} alert information: {TRIGGER. NAME} alert item: {TRIGGER. KEY1} problem details: {ITEM. NAME }:{ ITEM. VALUE} Current status: {TRIGGER. STATUS }:{ ITEM. VALUE1} event id: {EVENT. ID}

By default, an email notification is sent within one hour. The minimum value is 60 S.

6. Example

Next, let's take a look at the mail alarm information that the monitoring host cannot ping

Summary

During configuration, note that the script name corresponds to the configuration file.

 

 

 

Note:

Author: pursuer. chen

Blog: http://www.cnblogs.com/chenmh

All essays on this site are original. You are welcome to repost them. However, you must indicate the source of the article and clearly give the link at the beginning of the article.

Welcome to discussion

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.