Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

ZABBIX3.0 configure email alarm

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Environment introduction:

Zabbix version: 3.0.5

Operating system: Centos6.8

IP address: 192.168.10.150

two。 Install sendEmail

SendEmail is a free, lightweight, command-line SMTP mail client.

If you need to use the command line to send email, then sendEmail is the perfect choice: easy to use and powerful.

Wget-P / tmp # install component yum install perl-Net-SSLeay perl-IO-Socket-SSL-y # extract the package and copy the command to / usr/local/bin tar-zxvf / tmp/sendEmail-v1.56.tar.gz-C / tmpcp / tmp/sendEmail-v1.56/sendEmail / usr/local/bin/chmod + x zabbix:zabbix / usr/local/bin/sendEmail

3. Create a zabbix alarm script directory

Mkdir-p / usr/local/zabbix/alertscriptschown-R zabbix:zabbix / usr/local/zabbix/alertscripts

4. Modify zabbix server configuration file to specify script directory

Vim / usr/local/zabbix/etc/zabbix_server.conf# modifies the AlertScriptsPath variable to the following, which is about 448 lines AlertScriptsPath=/usr/local/zabbix/alertscripts

5. Test sendEmail to send email (choose one with step 62)

SendEmail-f from@163.com-t to@qq.com-s smtp.163.com-u 'test'-o message-content-type=html-o message-charset=utf8-xu from@163.com-xp 'passwd'-m 'test'Dec 24 23:01:59 zabbix sendEmail [3612]: Email was sent email address #-f from@163.com # Sender email address #- T to@qq.com # recipient email address #-s smtp.163.com # smtp server address of sender mailbox #-u 'test' # message title #-o message-content-type=html # message content format is html#-o message-charset=utf8 # message content is encoded as utf8#-xu from@163.com # sender mailbox login user name #-xp 'passwd' # sender mailbox login password #-m' email # email content # write mail alert script vim / usr _ Bashto=$1subject=$2message=$3smtp_server= "smtp.163.com" / usr/local/bin/sendEmail-f from@163.com-t "$to"-s "$smtp_server"-u "$subject"-o message-content-type=html-o message-charset=utf8-xu from@163.com-xp "passwd"-m "$message" chmod + x sendEmail.shchown zabbix.zabbix sendEmail.sh

6. Use the 163 agent to send mail (choose one from step 52)

Yum install-y mailx# can set the sender address by adding two lines of 163authentication at the bottom of the file vim / etc/mail.rc# Smtp server set from=pyslinux@163.com smtp=smtp.163.com# sets sender smtp authentication username and password (since set smtp-auth-user=pyslinux@163.com smtp-auth-password= password is set here after smtp is enabled) set smtp-auth-user=pyslinux@163.com smtp-auth-password= password smtp-auth=login# test email sends mail-s' password

< /etc/passwd# 编写脚本vim /usr/local/zabbix/alertscripes/mail.sh#!/bin/bashecho "$3"|mail -s "$2" "$1"chmod +x /usr/local/zabbix/alertscripes/mail.sh 7. zabbix页面设置报警 I:进入到zabbix管理界面---->

Manage-> alarm Media Type-> create Media Type

Name write the full name of the media type name, type selection script and script name to be displayed, and add three corresponding script parameters: recipient, title, content

{ALERT.SENDTO}

{ALERT.SUBJECT}

{ALERT.MESSAGE}

Select enabled and click add

II: main interface-> manage-> user-> create user

Fill in the user's alias and password Select language to create user group-- > add user to user group-- > check debug mode permissions-- > combine permissions-- > add-> Select the host that needs to alarm-then add IV: main interface-> configuration-> Action event source selection trigger-> create Action Click Action-- > Action Action-- > New -- > the following default procedure lasts for 60 seconds Step 1-2, the operation type is to send a message, send it to the user, and the user group (select the new user and group), only send to select the new media type and add it. Explanation: the default step is 1-1, that is, from 1 to 1. Once the failure occurs, the sendEmail.sh script is executed to send an alarm email to the Admin user and the zabbix administrator group. If the fault lasts for 1 hour, it will only be sent once. If you change it to 1-0, it means there is no limit. The infinite send interval is the default duration of 60 seconds. Then 60 emails will be sent in an hour. (the duration of the step indicates how many seconds to send.) if you need to send an SMS alarm, you can create a new action and select the SMS script.

8. Open the mailbox to see if you have received the mail, or use the zabbix page to see if the email has been sent: report-> Action Log

I did receive an email, but the content is a little unfriendly, the solution:

You can modify the content format of the action log

Click configure-> actions-> Open the action you just created

Add after each line of default information

Such as:

Trigger: {TRIGGER.NAME}

Trigger status: {TRIGGER.STATUS}

Trigger severity: {TRIGGER.SEVERITY}

Trigger URL: {TRIGGER.URL} Item values:

1. {ITEM.NAME1} ({HOST.NAME1}: {ITEM.KEY1}): {ITEM.VALUE1}

2. {ITEM.NAME2} ({HOST.NAME2}: {ITEM.KEY2}): {ITEM.VALUE2}

3. {ITEM.NAME3} ({HOST.NAME3}: {ITEM.KEY3}): {ITEM.VALUE3}

Original event ID: {EVENT.ID}

Because I use the sendEmail.sh script to specify that the format is html, so the line break is

Or change it to Chinese prompt:

The default information is the same as the recovery information

Alarm host: {HOSTNAME1}

Alarm time: {EVENT.DATE} {EVENT.TIME}

Alarm level: {TRIGGER.SEVERITY}

Alarm message: {TRIGGER.NAME}

Alarm item: {TRIGGER.KEY1}

Question details: {ITEM.NAME}: {ITEM.VALUE}

Current status: {TRIGGER.STATUS}: {ITEM.VALUE1}

Event ID: {EVENT.ID}

Reference website: http://www.cnblogs.com/rysinal/p/5834421.html

Reference website: http://www.iyunv.com/thread-22904-1-1.html

Reference website: http://www.centoscn.com/CentosServer/log/2013/0807/1168.html

Reference website: http://tongcheng.blog.51cto.com/6214144/1706712

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report