标签归档:SmokePing

Smokeping 发送告警邮件

smokeping 默认用sendmail发邮件,无法满足要求,改了一下源码,这样可以使用自定义方式发送邮件(如用QQ的smtp server来发告警邮件)。

首先需要安装 Authen::SASL 模块(auth 需要用的) 我用CPAN装的,不细说了

修改 smokeping/lib/Smokeping.pm

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#头上加
use Authen::SASL;
#定位到sendmail函数,改成下面这样
sub sendmail ($$$){
    my $from = shift;
    my $to = shift;
    $to = $1 if $to =~ /<(.*?)>/;
    my $body = shift;
    if ($cfg->{General}{mailhost} and
        my $smtp = Net::SMTP->new([split /\s*,\s*/, $cfg->{General}{mailhost}],Timeout=>5) ){
        $smtp->auth(split(/\s*,\s*/, $cfg->{General}{mailusr}),split(/\s*,\s*/, $cfg->{General}{mailpwd}));
        $smtp->mail($from);
        $smtp->to(split(/\s*,\s*/, $to));
        $smtp->data();
        $smtp->datasend($body);
        $smtp->dataend();
        $smtp->quit;
    } elsif ($cfg->{General}{sendmail} or -x "/usr/lib/sendmail"){
        open (M, "|-") || exec (($cfg->{General}{sendmail} || "/usr/lib/sendmail"),"-f",$from,$to);
        print M $body;
        close M;
    } else {
        warn "ERROR: not sending mail to $to, as all methodes failed\n";
    }
}
#找到  '_vars =>' ,把 mailusr mailpwd  加进去。不然不能启动哦!General configuration values valid for the whole SmokePing setup.
DOC
_vars =>
[ qw(owner imgcache imgurl datadir dyndir pagedir piddir sendmail offset
smokemail cgiurl mailhost mailusr mailpwd snpphost contact display_name
syslogfacility syslogpriority concurrentprobes changeprocessnames tmail
changecgiprogramname linkstyle precreateperms ) ],

然后修改配置文件
/etc/config

1
2
3
4
5
6
7
mailhost = smtp.qq.com
mailusr = noreply@qq.com
mailpwd = xxxxxxxxx

Smokeping的Master.Slave.线上配置

前言:

通常情况下,smokeping主机和被监控的主机之间都会存在网络延迟和丢包情况。因此现在比较热火的分布式,多节点监控架构似乎迫在眉睫,而smokeping完全支持master/slave多节点监控

优点:

smokeping的主从结构,默认是开启master和slave所有的检测指针去检测远程主机(当然这个选项也是有个参数可以控制,只让slave去检测远程主机)。一个master可以管理多个slave,而且slave配置起来也很简单
slave从master上获取自己的配置信息,所有的检测数据以及web呈现都在master上,slave只负责按照从master获取的配置信息进行数据检测,所以说master/slave的架构也只需要维护好master的配置文件即可,其他的信息slave都会动态获取到。
Smoking 检测分布式的检测方式是被动模式,由从节点启动时获得主节点的config 文件,然后进行数据检测收集,收集完毕后直接将数据提交给主节点。主从通信验证是通过类似于rsync的密码认证方式,在启动slave节点时指定–shared-secret=filename 来和主进行密码验证 继续阅读

SmokePing

SmokePing keeps track of your network latency:
  • Best of breed latency visualisation.
  • Interactive graph explorer.
  • Wide range of latency measurment plugins.
  • Master/Slave System for distributed measurement.
  • Highly configurable alerting system.
  • Live Latency Charts with the most ‘interesting’ graphs.
  • Free and OpenSource Software written in Perl written by Tobi Oetiker, the creator of MRTG and RRDtool
  • SmokePing Documentation

继续阅读