Zabbix implements email alarm and zabbix email alarm

Source: Internet
Author: User

Zabbix implements email alarm and zabbix email alarm

Note:

The Zabbix monitoring server and client have been deployed. The monitored host has been added, and Zabiix monitoring runs normally.

Purpose:

Set email alarms on the Zabbix server. When the monitored host goes down or reaches the preset trigger value, an alert email is automatically sent to the specified mailbox.

Specific operations:

The following operations are performed on the Zabbix Monitoring Server:

Note: Zabbix Monitoring Server

Operating System: CentOS

Use an external email account to send alarm email settings:

1. Disable sendmail or postfix

Service sendmail stop # disable

Chkconfig sendmail off # disable startup

Service postfix stop

Chkconfig postfix off

Note:

You do not need to start sendmail or postfix when using an external email account.

If you use an external email address to send an alarm email when sendmail or postfix is enabled, the system first reads the external email address.

Configuration information.

Ii. Install mailx

Yum install mailx # Installation

Mailx is compiled and installed in CentOS 5.x. The mailx version directly installed in yum is too old. If you use external mail to send emails, there will be problems.

Yum remove mailx # uninstall the old version mailx that comes with the System

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 # Extract

Cd mailx-12.4 # Go To The Directory

Make # compile

Make install UCBINSTALL =/usr/bin/install # install

Ln-s/usr/local/bin/mailx/bin/mail # create a soft connection from mailx to mail

Ln-s/etc/nail. rc/etc/mail. rc # create a soft connection to the mailx configuration file

3. Configure Zabbix server external mailbox

Vi/etc/mail. rc # edit and add the following information

Set from = xxx@163.com smtp = smtp.163.com // Add a sender, sending server

Set smtp-auth-user = xxx@163.com smtp-auth-password = 123456 // Add send hot mailbox and login password.

Set smtp-auth = login

: Wq! # Save and exit

Echo "zabbix test mail" | mail-s "zabbix" yyy@163.com

# Test sent mail, title zabbix, mail content: zabbix test mail, sent to the mailbox: yyy@163.com

# At this time, the mailbox yyy@163.com will receive a test mail from the xxx@163.com

4. Configure Zabbix server mail alarm

1. Open Zabbix

Management-alert media type-create media type

 

Name: Sendmail

Type: script

Script Name: sendmail. sh

Enabled: select

Archive

2. Set the Zabbix user's alarm email address

 

 

 

Type: Sendmail

Recipient: xxx@163.com

Other options are available by default.

To set

Status: Enabled

Archive

3. Set Zabbix to trigger the alarm.

Configuration-action-create action

Name: Action-Email

Default recipient: Fault {TRIGGER. STATUS}, server: {HOSTNAME1} occurrence: {TRIGGER. NAME} fault!

Default information:

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}

 

 

Recovery Information: Check

 

 

Recovery purpose: Restore {TRIGGER. STATUS}, server: {HOSTNAME1 }:{ TRIGGER. NAME} has been restored!

Recovery Information:

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}

Enabled: hook

 

Switch to operation options

New

Operation Type: send information

Send to user: add

Default information: Check

Select User: Admin

Select

Send only to: Sendmail

Archive

4. Add the Zabbix server mail sending script

Cd/usr/local/zabbix/share/zabbix/alertscripts # enter the script storage directory

Vi sendmail. sh # edit and add the following code

#! /Bin/sh

Echo "$3" | mail-s "$2" $1

: Wq! # Save and exit

Chown-R zabbix. zabbix/usr/local/zabbix/share/zabbix/alertscripts /*

Add the relative path of the script to the zabbix_server.conf File

AlertScriptsPath =/usr/local/zabbix/share/zabbix/alertscripts

# Set the script owner to a zabbix user

Chmod + x/usr/local/zabbix/share/zabbix/alertscripts/sendmail. sh

# Set the script execution permission

5. Test Zabbix alarm

Disable Zabbix Client Service

Service zabbix_agentd stop

View your xxx@163.com mailbox and receive an alert email

Enable Zabbix client service again

Service zabbix_agentd start

Viewing Your xxx@163.com mailbox will receive recovery mail

The alarm email sending setting is complete with the external email account.

Now, Zabbix mail alarm settings are complete.

 

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.