Zabbix monitoring sends an alert to multiple users by email

Source: Internet
Author: User

Zabbix is a monitoring software, and alarm is essential. This article mainly introduces the configuration process of zabbix alarm to multiple people by email.

 

Instructions on zabbix mail alarm Configuration:

1. Prepare a script for sending emails.

2. Modify the script path specified in the zabbix configuration file.

3. Associated Script Name

4. Set the email address and alarm time.

5. Configure an alarm trigger

6. add multiple users and send emails to multiple users at the same time

7. Mail Acceptance Test

 

1. Prepare a script for sending emails.

There are many ways to send emails. If you write scripts by yourself, you only need to follow the zabbix parameter passing format.

The format of parameters for zabbix sending:./sendmail. py recipient title email content

The Python mail sending script is as follows:

CAT/usr/local/zabbix/share/zabbix/alertscripts/sendmail_qs.py

#! /Usr/bin/Python #-*-coding: UTF-8-*-import smtplibimport sysfrom email. mime. text importmimetextimport time # reload (sys) # sys. setdefaultencoding ('utf8') current_time = time. strftime ('% Y-% m-% d % H: % m', time. localtime (time. time () mail_host = 'smtp .exmail.qq.com 'mail _ User =' [email protected] m' mail _ Pwd = '******' def send_email (content, mailto, get_sub): # MSG = mimetext (content. encode ('utf8'), _ subtype = 'html', _ charset = 'utf8') MSG = mimetext (content, _ subtype = 'plain ', _ charset = 'gb2312') MSG ['from'] = mail_user MSG ['subobject'] = get_sub MSG ['to'] = ",". join (mailto) Try: S = smtplib. smtp_ssl (mail_host, 465) s. login (mail_user, mail_pwd) s. sendmail (mail_user, mailto, MSG. as_string () s. close () failed t exception as E: Print 'exception: ', e Title = sys. argv [2] cont = "" ----------------------------------- Abstract: % s --------------------------------- time: % s hour "% (sys. argv [3], current_time) to_list = ['% s' % (sys. argv [1]),] withopen ('/tmp/sendmail_qs.log', 'AB') as F: f. write ('% s receive address: % s title: % s \ n' % (current_time, sys. argv [1], title) send_email (cont, to_list, title)

# The Python script finally records the sent mail logs to/tmp/sendmail. log.

# Modify mail_host, mail_user, and mail_pwd at the top of the page.

 

2. Modify the script path specified in the zabbix configuration file.

Echo 'alertscriptspath =/usr/local/zabbix/share/zabbix/alertscripts '>/usr/local/zabbix/etc/zabbix_server.conf

/Etc/init. d/zabbix_serverrestart

In this example, the installation directory of zabbix is in/usr/local/zabbix. You can manually modify it in different paths.


3. Associated Script Name

[Zabbix main panel, management, alert media, and media creation]

Enter the script name and the name in/usr/local/zabbix/share/zabbix/alertscripts.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/46/6B/wKiom1PyL8HCvKoxAAG6A110IL4944.jpg "style =" float: none; "Title =" 1 "alt =" wkiom1pyl8hcvkoxaag6a110il4944.jpg "/>


4. Set the email address and alarm time.

[Zabbix main panel, management, user, click User]

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/46/6C/wKioL1PyMNmh43vGAAHc8MYsLQQ203.jpg "Title =" 2 "style =" float: none; "alt =" wkiol1pymnmh43vgaahc8myslqq203.jpg "/>


Configure the user's email address

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/46/6C/wKioL1PyMY_D8HMeAADko0AJD4o971.jpg "Title =" 3.jpg" alt = "wkiol1pymy_d8hmeaadko0ajd4o971.jpg"/>

5. Configure an alarm trigger

[Zabbix main panel à configuration à Action à create action] configure alarm information

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/46/6B/wKiom1PyL8PRvCBZAAMSWbcmK9Q825.jpg "Title =" 4 "style =" float: none; "alt =" wkiom1pyl8prvcbzaamswbcmk9q825.jpg "/>


 

Configure alarm trigger conditions

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/46/6C/wKioL1PyMN3iQguLAAICe_vaWu0045.jpg "Title =" 5 "style =" float: none; "alt =" wkiol1pymn3iqgulaaice_vawu0045.jpg "/>

 

Recipient after setting the trigger Condition

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/46/6B/wKiom1PyL8bRaeD_AAGhrBMCNHI272.jpg "Title =" 6 "style =" float: none; "alt =" wkiom1pyl8braed_aaghrbmcnhi272.jpg "/>

6. add multiple users and send emails to multiple users at the same time

First, create a common user in manage.

Then, promote normal users to super administrators. Normal users do not have the permission to send emails if they are not promoted to a super administrator!

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/46/6C/wKioL1PyMN-CLpy1AAGwXJRr3ug580.jpg "Title =" 7 "style =" float: none; "alt =" wKioL1PyMN-CLpy1AAGwXJRr3ug580.jpg "/>

 

Add a new receiving user in configuration à action.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/46/6B/wKiom1PyL8iDMUh4AAHGhYxlhhU815.jpg "Title =" 8 "style =" float: none; "alt =" wkiom1pyl8idmuh4aahghyxlhhu815.jpg "/>

7. Mail Acceptance Test

Down the zabbix_agentd process of the client node. Wait for an email alert. By default, the agent sends an email for 5 minutes. That is, if no data is obtained for five times, an alert is triggered.

According to the test, zabbix does not send emails to multiple users by means of parallel mail. Instead of having multiple recipients at a time, execute two mail sending scripts.

Therefore, if the number of recipients is large, you can directly write all the recipients to the above Python email script, that is, do not call the recipients sent from zabbix. The disadvantage is that you need to manually modify the Python script when the recipient changes, instead of modifying the zabbix user configuration.

 

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/46/6B/wKiom1PyL8nh5JyPAAEiYU1jo10645.jpg "Title =" 9 "style =" float: none; "alt =" wkiom1pyl8nh5jypaaeiyu1jo10645.jpg "/>

 

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/46/6C/wKioL1PyMOKCcr9fAAGTQPp-TZ8101.jpg "Title =" 10 "style =" float: none; "alt =" wKioL1PyMOKCcr9fAAGTQPp-TZ8101.jpg "/>

 

 

The alarm configuration for zabbix multiplayer emails has been completed.


This article is from the "My hometown here" blog. For more information, contact the author!

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.