Smokeping配置调整
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 = >0%,*30*,>0%,*30*,>0% # in percent
comment = loss 1 packages in 30 continuous 3 times.
+manyloss type = loss
pattern = >15%,*30*,>15%,*30*,>15% # in percent
comment = loss 5 packages in 30 continuous 3 times.
+rttbad type = rtt
pattern = ==S,>50,>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配置调整的更多相关文章
- smokeping配置方法
smokeping配置加Nginx https://lala.im/2821.html (不完整)
- Flume中的flume-env.sh和log4j.properties配置调整建议(图文详解)
GC是内存的回收的意思. Flume中的flume-env.sh配置调整建议 [hadoop@master conf_HostInterceptor]$ pwd /home/hadoop/app/fl ...
- 第15.2节 PyCharm支持Python解释器的配置调整
上节介绍了PyCharm的安装与简单使用,本节介绍PyCharm相关的配置调整,以支持在PyCharm环境下集成Python解释器进行程序的编译. 一. 工程配置调整 在执行文件前,可能需要对PyCh ...
- 009.KVM配置调整
一 内存CPU调整 1.1 增大虚拟机内存 [root@kvm-host ~]# virsh shutdown vm01-centos6.8 [root@kvm-host ~]# virsh edit ...
- Smokeping配置
参考文档: 官网:http://oss.oetiker.ch/smokeping/ 参考:http://jaminzhang.github.io/monitoring/smokeping-deploy ...
- 虚拟机(Vmware)安装ubuntu18.04和配置调整(二)
二.配置修改 1.修改语言环境(settings->Region & Language) 选中中文简体(Chinese(simplified)),点击Apply 中文简体语言安装完成后, ...
- rgw的rgw_thread_pool_size配置调整
前言 在比对rgw的不同前端的区别的时候,官方说civetweb是通过线程池来控制连接的,beast是后面加入了流控相关的,这块一直也没有调整过相关的参数,然后通过ab压测了一下,还是有很明显的区别的 ...
- MySQL 5.6初始配置调整
原文链接: What to tune in MySQL 5.6 after installation原文日期: 2013年09月17日翻译日期: 2014年06月01日翻译人员: 铁锚 随着 大量默认 ...
- Smokeping配置完成之后出现Software error解决办法
下面是在浏览器中输入http://localhost/smokeping点击回车之后出现的错误: Software error: ERROR: creating /usr/local/smokepin ...
随机推荐
- Codeforces - 617E 年轻人的第一道莫队
我对莫队算法最为纠结的地方就是区间端点处,应该是像代码里那样理解吧 cnt[i]表示i出现的次数 maxn开2e6比较保险 /*H E A D*/ struct Query{ int l,r,id; ...
- Xtts v4变化&先决条件&已知问题
V4变化的主要有: 1.这个采购使用简化的命令.源的一个命令(--backup)和目标的一个命令(--restore). 2.此过程只需要在源和目标的$ TMPDIR(res.txt)之间复制 ...
- win 引用win32无效问题
我使用pycharm 安装: python window 10 下安装win32 module 问题:安装后引用win32api等依赖,无效,但是目录下确实已经安装: 解决方案: ${python_h ...
- Python 中下划线的 5 种含义
详细请参考这篇文章 单前导下划线:_var 单末尾下划线:var_ 双前导下划线:__var 双前导和末尾下划线:__var__ 单下划线:_
- 在ZYNQ-7000平台上利用PS点亮PL上的LED灯
在ZYNQ-7000平台上利用PS点亮PL上的LED灯 1.实验方案 图1 实验方案系统框图 2.具体步骤 2.1.vivado工程建立 ①打开vivado集成开发环境,点击“Create Pr ...
- 【python数据分析】利用Anaconda在window上搭建数据分析环境
由于在进行数据分析过程中,需要安装一些第三方库,导致python总会报一些错误,现将通过利用Anaconda搭建数据分析环境,已测可用. 1.到官网上下载python:https://www.pyth ...
- Django 入门项目案例开发(上)
关注微信公众号:FocusBI 查看更多文章:加QQ群:808774277 获取学习资料和一起探讨问题. Django 入门案例开发(中) http://www.cnblogs.com/focusBI ...
- hdu 5242——Game——————【树链剖分思想】
Game Time Limit:1500MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- D3(v5) in TypeScript 坐标轴之 scaleBand用法
在学习d3时候,发现在TS中实现D3的坐标轴中遇到一些错误,而这些错误却不会存在于js(因为ts的类型检查)写法中,因此做下笔记: import * as d3 from 'd3';import * ...
- 利用pandas生成csv文件
# -*- coding:UTF-8 -*- import json from collections import OrderedDict with open('dns_status.json',' ...