许久没安装smokeping报警 体验安装,包含踩过的坑(看其他人的文章)
1、安装模块
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
模块这样就安装完成了
2、vi /usr/local/smokeping/lib/Smokeping.pm
如下:
-- perl --
package Smokeping;
use Authen::SASL;
use strict;
添加到这两个中间 (注意后面的符号别忘了)
然后检索(按一下esc再按/ 然后输入后面的字符)$smtp->mail($from);(大概在260行左右)
在他的上面添加一个
$smtp->auth(split(/\s,\s/, $cfg->{General}{mailusr}),split(/\s,\s/, $cfg->{General}{mailpwd}));
第二步检索qw(owner imgcache然后在mailhost的后面添加mailuser mailpwd(cgiurl mailhost mailuser mailpwd snpphost)注意中间是有空格的 保存退出
最后一步 编辑vi /user/local/smokeping/etc/config
在General的下面找到contact 在这项下面编辑
mailhost = smtp.163.com
mailuser = @163.com(输入自己的邮箱)
mailpwd = (这是一个大坑,不是你登录邮箱的密码,是邮箱给的,在163邮箱设置里POP/SMTP然后右边有授权密码,几个大写的字母和数字组成的)
自定义alerts告警策略
- Alerts
to = @.com(指的是报警邮箱发送给谁,添加多个的话用,隔开)
from = @163.com(上面授权密码的邮箱)
+bigloss
type = loss
in percent
pattern = ==0%,==0%,==0%,==0%,>0%,>0%,>0%
comment = suddenly there is packet loss
+someloss
type = loss
in percent
pattern = >0%,12,>0%,12,>0%
comment = loss 3 times in a row
+startloss
type = loss
in percent
pattern = ==S,>0%,>0%,>0%
comment = loss at startup
+rttdetect
type = rtt
in milli seconds
pattern = <10,<10,<10,<10,<10,<100,>100,>100,>100
comment = routing messed up again ?
+hostdown
type = loss
in percent
pattern = ==0%,==0%,==0%, ==U
comment = no reply
+lossdetect
type = loss
in percent
pattern = ==0%,==0%,==0%,==0%,>20%,>20%,>20%
comment = suddenly there is packet loss**
把/user/local/smokeping/etc/config中的节点随便一个改成192.168.1.1不存在的IP地址
然后重启smokeping服务(/user/local/smokeping/bin/smokeping --restart)
邮件就可以发送了