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 mail alarm detailed configuration + switch traffic monitoring alarm

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

Share

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

1. Download software

Wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

two。 Create a directory

Mkdir / usr/local/bin

3. Decompression software

Tar zxf sendEmail-v1.56.tar.gz-C / usr/src

4. Enter the directory

Cd / usr/src/sendEmail-v1.56

5. Copy files and set permissions

Cp-a sendEmail / usr/local/binchmod + x / usr/local/bin/sendEmail

6. Install component

Yum install perl-Net-SSLeay perl-IO-Socket-SSL-y

7. Test the mail function

# / usr/local/bin/sendEmail-f from@163.com-t to@qq.com-s smtp.163.com-u "I am the subject of the email"-o message-content-type=html-o message-charset=utf8-xu from@163.com-xp 123456-m "I am the content of the email"

Command description:

/ usr/local/bin/sendEmail command main program-f from@163.com sender mailbox-t to@163.com recipient mailbox-smtp server of s smtp.163.com sender mailbox-u "I am the subject of mail" message title-o message-content-type=html message content format Html indicates that it is in html format-o message-charset=utf8 message content coding-user name of xu from@163.com sender mailbox-xp 123456 sender mailbox password-m "I am email content" message specific content

There is a problem display

In / usr/local/bin

Vim sendEmail

1906 lines

If (! IO::Socket::SSL- > start_SSL ($SERVER, SSL_version = > 'SSLv3 TLSv1'))

Modify it to if (! IO::Socket::SSL- > start_SSL ($SERVER))

That is, do not specify the version of SSL, let the program choose. In this way, you can send mail after modification, but there is also a prompt message, which does not affect the use of the mail function.

8. View edit script configuration

Enter the specified directory customized by zabbix. Here is / usr/local/zabbix

You can see how the AlertScriptsPath variable in the zabbix_server.conf configuration file is defined.

Vim / usr/local/zabbix/etc/zabbix_server.conf

Find the AlertScriptsPath option and customize the location

# Option: AlertScriptsPath# Full path to location of custom alert scripts.# Default depends on compilation options.## Mandatory: no# Default:# AlertScriptsPath=$ {datadir} / zabbix/alertscriptsAlertScriptsPath=/usr/local/zabbix/alertscripts

Cd / usr/local/zabbix/alertscripts/

9. Edit script

Vim sendEmail.sh

The contents are as follows:

#! / bin/bashto=$1subject=$2body=$3/usr/local/bin/sendEmail-f from@163.com-t "$to"-s smtp.163.com-u "$subject"-o message-content-type=html-o message-charset=utf8-xu from@163.com-xp password-m "$body"

Description:

Replace from@163.com with your own sending mailbox

Smtp.163.com represents the smtp server of the mailbox. It is shown here that 163mailbox is used to replace your own mailbox SMTP address.

Replace password with sending mailbox password

10. After editing, give permission to the script

Chmod + x sendEmail.shchown zabbix.zabbix sendEmail.sh

11.web interface configuration

Go to the zabbix management page

Click manage-> alarm Media Type Click create Media Type on the far right

Enter the name of the script, select the type of script, and add the following three parameters, corresponding to the three parameters required by the sendEmail.sh script: recipient address, subject, and details.

{ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE}

Explanation: after many people install zabbix 3.0, the script they write has been sent unsuccessfully and can be executed manually.

That's because after zabbix3.0, you can customize the parameters. So if you don't write parameters, it won't pass parameters.

This problem does not exist in version 2.x, and 3 parameters are passed by default.

Click the Admin user

Click Quote Media-add

Select the sendEmail.sh script and enter the recipient's email address

Click on the user group, click on the call mode after zabbix administrator, click on it, and it is enabled.

Click Zabbix administrators group name point permissions-> add

Select all Click Update.

Click configure-> Action Click the default action:

Click Action-> Edit:

Modify the following (according to the actual situation, please fill in according to your own needs, here just to show)

Modification duration is 60 seconds

Modify step 3, which means that 3 actions are triggered

Select user Admin

Choose to send only to sendEmail.sh

Click Update

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. Infinite transmission

The interval is 60 seconds by default. Then 60 emails will be sent in an hour.

If you need SMS alarm, you can create a new action and select the SMS script.

I'll add a condition here, after triggering:

After the message is sent, the content is:

Click report-> Action log to see the number of times the action was triggered. Only three times, unless the state of the test host changes, that is, normally, it will be triggered once, otherwise it will not be triggered again.

You can see that the contents of the e-mail are all piled together, there is no line change, a little upset.

You can modify the content format of the action log

Click configure-> actions-> Report problems to Zabbix administrators

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 Information: {TRIGGER.NAME} alarm Project: {TRIGGER.KEY1} question details: {ITEM.NAME}: {ITEM.VALUE} current status: {TRIGGER.STATUS}: {ITEM.VALUE1} event ID: {EVENT.ID}

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

Traffic threshold trigger setting of the switch

Select the switch port to be monitored

Set the threshold N to represent btye

After the setting is successful, you can see the threshold trigger on the graph.

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