smokeping两种邮件报警方式

一 、自带sendmail报警

修改这两句话
to = 收件邮箱,多个逗号分隔
from = smokealert@本机IP

/usr/local/smokeping/bin/smokeping --reload --logfile=/usr/local/smokeping/smokeping.log
重新加载配置文件

二、通过修改模块文件用QQ等邮箱发件

需要perl的Authen::SASL模块

cpan Authen::SASL

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

#头上加

use Authen::SASL;

#定位到sendmail函数,默认新版本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 ) ],

配置完成后修改配置文件/opt/smokeping/etc/config ,增加邮件服务器的配置:

mailhost = smtp.361way.com
mailusr = monitor@361way.com
mailpwd = xxxxxxxxx

自定义alerts告警策略

如下定义了几种告警策略,bigloss 、someloss等

*** Alerts ***
to = admin@361way.com
from = monitor@361way.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

以上几种告警,这里选取三种说明如下:

someloss: 如果在12次检查中出现了3次丢包的情况(不论丢多少个包),就进行alert;
rttbad:
如果连续出现两次50毫秒以上的延时,就进行alert;
rrtdetect:
之前5次检查延时都少于10毫秒,前6次检查延时都少于100毫秒,第7次开始连续3次检查延时都大于100毫秒的话,就进行alert。

2、策略应用

在target里面加上相应的策略配置即可,如下:

++ 361way
menu = 361way_host
title =361way.com
host = www.361way.com
alerts = someloss,hostdown

主机一旦出现告警,就会通过邮件发送到我们事先配置的邮箱中,类似下图:

smokeping-alert

上图中的邮件告警内容也可以进行自定义格式输出和修改,这个还是修改Smokeping.pm文件,修改其中如下部分即可:

my $default_mail = <<DOC;
Subject: [SmokeAlert] <##ALERT##> <##WHAT##> on <##LINE##>
<##STAMP##>
Alert "<##ALERT##>" <##WHAT##> for <##URL##>
Pattern
-------
<##PAT##>
Data (old --> now)
------------------
<##LOSS##>
<##RTT##>
Comment
-------
<##COMMENT##>
DOC

*** Alerts ***

to = zouyunhao@aspire-tech.com,minliang@aspire-tech.com,

from = smokealert@192.168.2.14

+someloss

type = loss

pattern = &gt;0%,*30*,&gt;0%,*30*,&gt;0% # in percent

comment = loss 1 packages in 30 continuous 3 times.

+manyloss type = loss

pattern = &gt;15%,*30*,&gt;15%,*30*,&gt;15% # in percent

comment = loss 5 packages in 30 continuous 3 times.

+rttbad type = rtt

pattern = ==S,&gt;50,&gt;50 # in milliseconds

comment = For more than two consecutive 50-millisecond delay.

(1)to 表示接受所有报警的邮箱,如果需要在特定的节点报警发送到特定的邮箱

则在该节点上增加alertee = 13828466531@139.com即可。

(2)manyloss 表示30个包丢15%的情况 连续出现3次就发报警。

(3)someloss 表示30个包丢1个,连续出现3次就发送报警;rttbad表示连续两个包延迟超过50ms就发送报警。


Smokeping配置调整的更多相关文章

  1. smokeping配置方法

    smokeping配置加Nginx https://lala.im/2821.html  (不完整)

  2. Flume中的flume-env.sh和log4j.properties配置调整建议(图文详解)

    GC是内存的回收的意思. Flume中的flume-env.sh配置调整建议 [hadoop@master conf_HostInterceptor]$ pwd /home/hadoop/app/fl ...

  3. 第15.2节 PyCharm支持Python解释器的配置调整

    上节介绍了PyCharm的安装与简单使用,本节介绍PyCharm相关的配置调整,以支持在PyCharm环境下集成Python解释器进行程序的编译. 一. 工程配置调整 在执行文件前,可能需要对PyCh ...

  4. 009.KVM配置调整

    一 内存CPU调整 1.1 增大虚拟机内存 [root@kvm-host ~]# virsh shutdown vm01-centos6.8 [root@kvm-host ~]# virsh edit ...

  5. Smokeping配置

    参考文档: 官网:http://oss.oetiker.ch/smokeping/ 参考:http://jaminzhang.github.io/monitoring/smokeping-deploy ...

  6. 虚拟机(Vmware)安装ubuntu18.04和配置调整(二)

    二.配置修改 1.修改语言环境(settings->Region & Language) 选中中文简体(Chinese(simplified)),点击Apply 中文简体语言安装完成后, ...

  7. rgw的rgw_thread_pool_size配置调整

    前言 在比对rgw的不同前端的区别的时候,官方说civetweb是通过线程池来控制连接的,beast是后面加入了流控相关的,这块一直也没有调整过相关的参数,然后通过ab压测了一下,还是有很明显的区别的 ...

  8. MySQL 5.6初始配置调整

    原文链接: What to tune in MySQL 5.6 after installation原文日期: 2013年09月17日翻译日期: 2014年06月01日翻译人员: 铁锚 随着 大量默认 ...

  9. Smokeping配置完成之后出现Software error解决办法

    下面是在浏览器中输入http://localhost/smokeping点击回车之后出现的错误: Software error: ERROR: creating /usr/local/smokepin ...

随机推荐

  1. [转] Akka实战:构建REST风格的微服务

    [From] http://www.yangbajing.me/2015/11/27/akka%E5%AE%9E%E6%88%98%EF%BC%9A%E6%9E%84%E5%BB%BArest%E9% ...

  2. session.flush()与session.clear()的区别及使用环境

    [From] http://blog.csdn.net/leidengyan/article/details/7514484 首先session是有一级缓存的,目的是为了减少查询数据库的时间,提高效率 ...

  3. Hibernate处理一个实体映射多张相同结构的数据表--动态映射

    [转自] http://blog.csdn.net/majian_1987/article/details/8725197 LZ在项目中需要处理这样一个业务,每天都有终端设备上传GPS位置信息到服务端 ...

  4. offset、client、scroll、screen的自己理解

    body是DOM对象里的body子节点,即 <body> 标签: documentElement 是整个节点树的根节点root,即<html> 标签: window.scree ...

  5. 设置Log文件每天生成一个(wamp)

    打开 Wamp的 httpd.conf文件 把下面两句话拷贝进去即可: 1.设置错误log的,    " 2.设置访问log的    " common    说明:bin/rota ...

  6. CF 305B——Continued Fractions——————【数学技巧】

    B. Continued Fractions time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  7. 白话SpringCloud | 第四章:服务消费者(RestTemple+Ribbon+Feign)

    前言 上两章节,介绍了下关于注册中心-Eureka的使用及高可用的配置示例,本章节开始,来介绍下服务和服务之间如何进行服务调用的,同时会讲解下几种不同方式的服务调用. 一点知识 何为负载均衡 实现的方 ...

  8. Oracle 数据类型详解

    数据类型(datatype)是列(column)或存储过程中的一个属性. Oracle支持的数据类型可以分为三个基本种类:字符数据类型.数字数据类型以及表示其它数据的数据类型. 字符数据类型 CHAR ...

  9. 【转】常用的邮箱服务器(SMTP、POP3)地址、端口

    gmail(google.com)POP3服务器地址:pop.gmail.com(SSL启用 端口:995)SMTP服务器地址:smtp.gmail.com(SSL启用 端口:587) 21cn.co ...

  10. 在浏览器中对访问的网页中的cookie添加和修改

    做权限相关的东西,使用到了cookie,关于它的安全性,cookie在浏览器中,通过插件是可以对其进行修改的,如下: 1.FireFox 安装Edit This Cookie 插件,之后点击插件图标即 ...