Network monitoring smokeping email alert (2)

Network monitoring smokeping build configuration (1)
network monitoring smokeping email alert (2)

Preface: There are two types of email alerts for smokeping, one is its own sendmail, the other is to call an external mailbox (qq, 163, etc.), the second is recommended. The smokeping warning tutorials I found on the Internet are all the same. 9 of the 10 pieces are the same. To put it bluntly, I just copy and paste. Some places I can’t understand, but I can’t find other articles. I can only figure it out by myself. It may be because of my limited ability. It took a day to send the alert email. I will try my best to explain in detail below.

1. Add external mail configuration

a. Install Authen::SASL module

cd /tmp
wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/Authen-SASL-2.12.tar.gz
chmod a+x Authen-SASL-2.12.tar.gz
tar zxvf Authen-SASL-2.12.tar.gz
cd Authen-SASL-2.12
perl Makefile.PL
make test
make install   //安装完成

b. Modify smokeping/lib/Smokeping.pm

vi /usr/local/smokeping/lib/Smokeping.pm  //找到对应安装位置,编辑

Modification 1: Add a line at the beginning of the text

use Authen::SASL      

Modification 2: Retrieve sendmail and add a line in the following position

$smtp->auth(split(/\s*,\s*/, $cfg->{General}{mailusr}),split(/\s*,\s*/, $cfg->{General}{mailpwd}));

Insert picture description here
Modification 3: Retrieve _vars, add mailusr and mailpwd parameters
Insert picture description here

2. Modify the smokeping configuration file

vi /usr/local/smokeping/etc/config
#这里也是三处位置修改

Modification 1: Add the password of the mailbox server account under General
Insert picture description here
Modification 2: Add the email account for sending and receiving alarms under Alerts. The following are several commonly used options for triggering alarms, and you can also edit them here.

Insert picture description here
Modification 3: Add the monitoring project test under Targets at the end, and select someloss, hostdown as the alarm options.
Insert picture description here

++ test
menu = test
title =test
alerts = someloss,hostdown  //监控阈值,在alerts中有多种可供选择
host = 192.168.1.1  //测试ip随意填

Restart project

/usr/local/smokeping/bin/smokeping --restart
//这个时候关闭主机就可以收到告警邮件了

3. Edit email content

Still edit in Smokeping.pm:

vi /usr/local/smokeping/lib/Smokeping.pm

Retrieve $default_mail and modify the contentInsert picture description here

Guess you like

Origin blog.csdn.net/qq_43316775/article/details/109446171