更多内容请点击 我的博客 查看,欢迎来访。
选择机房时,需要知道机房的网络请况,就需要用到网络监控软件smokeping。
smokeping由Perl语言写成,底层依赖于rrdtool和fping。
主要是监视网络性能,包括常规的ping
,用echoping
监控www服务器性能,监控dns查询性能和监控ssh性能等。底层时以rrdtool做支持,使用画图来表示网络丢包和延迟。
从监控图上的延时与丢包能分辨出你机房的网络是否稳定,是否为多线,是否为BGP机房,到各城市的3个运营商之间的网络,各是什么情况,如果出现问题,如何有针对性的解决。而且如果选择新机房的时候,可以根据smokeping的监控结果来判断这个机房是否适合。
smokeping整个系统正常运行需要:web服务器软件、smokeping主服务、探针,rrdtool。
smokeping拥有直观高效且漂亮的webUI,因此需要借助第三方web服务,默认使用的是apache服务,同时需要启用cgi模块。
smokeping主服务即smokeping工作进程,负责在后台(也可以前台)执行监测任务。
smokeping实际使用的监测工具即探针。默认探针是fping,常用探针例如:
fping
默认探针,使用icmp协议,可并发检测目标RTT(Round-Trip Time)数值echoping
echo服务检测,使用tcp/udp协议,默认端口号7tcpping
tcp端口检测,使用tcp协议监测端口连通性和时延更多关于探针的介绍可以参阅官方文档。
rrdtool(Round Robin Database Tool)即轮询调度数据库工具,使用C语言写成,是一种强大的绘图引擎,兼有时序数据库和绘图两种功能。rrdtool被许多监控平台所使用,如smokeping、cacti、open-falcon等。
访问 https://oss.oetiker.ch/smokeping/doc/smokeping_install.en.html 可以看到安装步骤。
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@localhost ~]# uname -r
3.10.0-1062.4.1.el7.x86_64
smokeping需要依赖系统上的其他工具和服务,除了Unix操作Perl组件。
[root@localhost ~]# yum -y install wget vim curl
[root@localhost ~]# yum -y install gcc gcc-c++ popt-devel
Smokeping使用RRDtool进行记录和绘图。如果linux提供了一个带有perl支持的rrdtool包,那么可以使用它。如果没有或安装新版
[root@localhost ~]# yum install rrdtool perl-rrdtool openssl-devel -y
smokeping 2.7.2 以上需要 fping4.0 以上,因此需要手动编译。可以访问 http://www.fping.org/ 下载
[root@localhost ~]# wget http://www.fping.org/dist/fping-4.2.tar.gz
[root@localhost ~]# tar -xzf fping-4.2.tar.gz
[root@localhost ~]# cd fping-4.2
[root@localhost fping-4.2]# ./configure
[root@localhost fping-4.2]# make && make install
需要它来运行echoping探测,做tcp ping,访问 https://github.com/bortzmeyer/echoping/ 进行查看。 http://bortzmeyer.github.io/echoping/ 官方说明,不在积极维护了。
[root@localhost ~]# wget https://fossies.org/linux/misc/old/echoping-6.0.2.tar.gz
[root@localhost ~]# tar xzf echoping-6.0.2.tar.gz
[root@localhost ~]# cd echoping-6.0.2
[root@localhost echoping-6.0.2]# yum install -y popt-devel
[root@localhost echoping-6.0.2]# ./configure # 如果报错使用下面的配置
[root@localhost echoping-6.0.2]# ./configure --with-ssl --without-libidn
[root@localhost echoping-6.0.2]# make && make install
http://httpd.apache.org/
重要的是,要有一个web服务器,它允许运行CGI,最好是FastCGI脚本。如果使用的是Apache,强烈建议使用suexec系统作为特定用户运行CGI脚本。
有关更多信息,请查看 http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html 和 http://httpd.apache.org/docs/2.2/mod/mod_suexec.html 。
注意smokeping是fcgi程序,因此apache 需要安装mod_fcgid
, http的版本是 2.4.6
[root@localhost ~]# yum install httpd httpd-devel -y
[root@localhost ~]# yum install mod_fcgid -y
[root@localhost ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl start httpd
# 查看Apache默认监听端口
[root@localhost ~]# cat /etc/httpd/conf/httpd.conf | grep Listen | grep -v "#"
Listen 80
# 查看端口及服务
[root@localhost ~]# netstat -antp | grep httpd
tcp6 0 0 :::80 :::* LISTEN 8572/httpd
# 但是外部是不同的,需要开启CentOS的防火墙fireall-cmd
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=80/tcp
success
# 操作完成后重载
[root@localhost ~]# firewall-cmd --reload
success
这时候访问该主机的IP http://xxx.xxx.xxx.xxx/ 即可以看到Apache的页面。
[root@localhost ~]# yum install perl-core -y
安装的版本为 smokeping-2.7.3 ,为2019年11月16日最新
[root@localhost ~]# wget https://oss.oetiker.ch/smokeping/pub/smokeping-2.7.3.tar.gz
[root@localhost ~]# tar xzf smokeping-2.7.3.tar.gz
[root@localhost ~]# cd smokeping-2.7.3
[root@localhost smokeping-2.7.3]# ./configure --prefix=/opt/smokeping
** Ready to install Smokeping ******************************
Settings:
PERL5LIB = not set
PERL = /usr/bin/perl
The Smokeping Makefiles use GNU make functionality.
Continue installation with
/usr/bin/gmake install
出现上面的错误,表示没有指定PERL5LIB
,下面将加上
[root@localhost smokeping-2.7.3]# ./configure --prefix=/opt/smokeping PERL5LIB=/usr/lib64/perl5/
** Ready to install Smokeping ******************************
Settings:
PERL5LIB = /usr/lib64/perl5/
PERL = /usr/bin/perl
The Smokeping Makefiles use GNU make functionality.
Continue installation with
/usr/bin/gmake install
[root@localhost smokeping-2.7.3]# /usr/bin/gmake install
Making install in thirdparty
gmake[1]: 进入目录“/root/smokeping-2.7.3/thirdparty”
GEN touch
Successfully installed FCGI-0.78
Successfully installed HTML-Tagset-3.20
Successfully installed HTML-Parser-3.72
Successfully installed CGI-4.40 (upgraded from 3.59)
Successfully installed CGI-Fast-2.13 (upgraded from 1.09)
Successfully installed Config-Grammar-1.12
Successfully installed Socket6-0.29
Successfully installed Net-SSLeay-1.85
Successfully installed Mozilla-CA-20180117
Successfully installed IO-Socket-SSL-2.060
Successfully installed Digest-HMAC-1.03
Successfully installed Net-Telnet-3.04
Successfully installed Net-OpenSSH-0.78
Successfully installed Net-SNMP-v6.0.1
Successfully installed Convert-ASN1-0.27
Successfully installed perl-ldap-0.65
Successfully installed IO-Socket-IP-0.39
Successfully installed Net-DNS-1.19
Successfully installed IO-Tty-1.12
Successfully installed URI-1.74
Successfully installed LWP-MediaTypes-6.02
Successfully installed Encode-Locale-1.05
Successfully installed IO-HTML-1.001
Successfully installed HTTP-Date-6.02
Successfully installed HTTP-Message-6.18
Successfully installed File-Listing-6.04
Successfully installed HTTP-Negotiate-6.01
Successfully installed HTTP-Daemon-6.01
Successfully installed Try-Tiny-0.30
Successfully installed Net-HTTP-6.18
Successfully installed HTTP-Cookies-6.04
Successfully installed WWW-RobotRules-6.02
Successfully installed libwww-perl-6.36
Successfully installed ExtUtils-MakeMaker-7.34 (upgraded from 6.63_02)
Successfully installed Net-IP-1.26
Successfully installed Data-HexDump-0.02
Successfully installed Authen-Radius-0.29
Successfully installed Path-Tiny-0.108
38 distributions installed
# 安装成功
需要建立三个文件夹,data
用来存放 rrd 文件,var
用来存放 smokeping 的 pid,/var/log
用来存放 smokeping.log
[root@localhost ~]# cd /opt/smokeping
# 从示例文件中,可以看到需要创建下面即可目录
[root@localhost smokeping]# cat etc/config.dist | grep '/opt/smokeping'
imgcache = /opt/smokeping/cache
datadir = /opt/smokeping/data
piddir = /opt/smokeping/var
smokemail = /opt/smokeping/etc/smokemail.dist
tmail = /opt/smokeping/etc/tmail.dist
template = /opt/smokeping/etc/basepage.html.dist
secrets=/opt/smokeping/etc/smokeping_secrets.dist
# 创建需要的目录
[root@localhost smokeping]# mkdir data cache var
[root@localhost smokeping]# chown apache:apache cache data var
[root@localhost smokeping]# chmod 777 data cache var
# 创建日志文件
[root@localhost smokeping]# touch /var/log/smokeping.log
[root@localhost smokeping]# chown apache:apache /var/log/smokeping.log
[root@localhost smokeping]# pwd
/opt/smokeping
# 查看有哪些文件
[root@localhost smokeping]# ls
bin cache data etc htdocs lib log share
[root@localhost smokeping]# ls etc/
basepage.html.dist config.dist examples smokemail.dist smokeping_secrets.dist tmail.dist
[root@localhost smokeping]# ls htdocs/
css js smokeping.fcgi.dist
# 创建smokeping的配置文件
[root@localhost smokeping]# cp etc/config.dist etc/config
# 创建smokeping 页面启动文件
[root@localhost smokeping]# cp htdocs/smokeping.fcgi.dist htdocs/smokeping.fcgi
# 里面的内容如下,通过smokeping_cgi脚本配合config配置文件启动
[root@localhost smokeping]# cat htdocs/smokeping.fcgi
#!/bin/sh
exec /opt/smokeping/bin/smokeping_cgi /opt/smokeping/etc/config
# basepage.html 是webUI的模板页面,修改此文件可以对页面默认的颜色以及其他样式做定制
[root@localhost smokeping]# cp etc/basepage.html.dist etc/basepage.html
# 用于设定主从验证
[root@localhost smokeping]# cp etc/smokeping_secrets.dist etc/smokeping_secrets
[root@localhost smokeping]# sed -i 's#cgiurl = http://some.url/smokeping.cgi#cgiurl = http://192.168.99.101/smokeping.cgi#g' /opt/smokeping/etc/config
# 图片url可以不做修改【不建议修改】
[root@localhost smokeping]# sed -i 's#imgurl = cache#imgurl = http://192.168.99.101/cache#g' /opt/smokeping/etc/config
# 默认检测时间300秒修改60秒
[root@localhost smokeping]# sed -i 's#step = 300#step = 60#g' /opt/smokeping/etc/config
# 默认ping20次,修改为60秒ping60次
[root@localhost smokeping]# sed -i 's#pings = 20#pings = 60#g' /opt/smokeping/etc/config
# 修改详情图detail显示高度,默认为200(第二处height)
[root@localhost smokeping]# sed -i 's#height = 200#height = 600#g' /opt/smokeping/etc/config
# 修改概览图overview显示高度,默认为50(第一处height)
[root@localhost smokeping]# sed -i 's#height = 50#height = 200#g' /opt/smokeping/etc/config
# 修改默认模板页面
[root@localhost smokeping]# sed -i 's#template = /opt/smokeping/etc/basepage.html.dist#template = /opt/smokeping/etc/basepage.html#g' /opt/smokeping/etc/config
# 修改主从默认密码验证
[root@localhost smokeping]# sed -i 's#secrets=/opt/smokeping/etc/smokeping_secrets.dist#secrets=/opt/smokeping/etc/smokeping_secrets#g' /opt/smokeping/etc/config
# 修改fping默认位置,先找到fping位置:whereis fping | awk '{print $2}',进行一键替换
[root@localhost smokeping]# sed -i 's#binary = /usr/sbin/fping#binary = '`whereis fping | awk '{print $2}'`'#g' /opt/smokeping/etc/config
# 查看config中自己修改后的内容
[root@localhost smokeping]# egrep "cgiurl|imgurl|step|pings|height|template|secrets|binary" etc/config
imgurl = cache
# imgurl = http://192.168.99.101/cache
cgiurl = http://192.168.99.101/smokeping.cgi
step = 60
pings = 60
# consfn mrhb steps total
template = /opt/smokeping/etc/basepage.html
height = 200
height = 600
binary = /usr/local/sbin/fping
secrets=/opt/smokeping/etc/smokeping_secrets
# 图片浏览器支持中文显示,防止中文乱码
# 中文支持修改第1处,安装字体
[root@localhost smokeping]# yum -y install wqy-zenhei-fonts.noarch
# 中文支持修改第2处,在presentation添加utf-8中文字符集,解决图乱码问题
[root@localhost smokeping]# vim /opt/smokeping/etc/config
# 省略
*** Presentation ***
# 添加这一行
charset = utf-8
# 省略
# 中文支持修改第3处,【实际测试可以不用加】
[root@localhost smokeping]# vim /opt/smokeping/lib/Smokeping/Graphs.pm
# 大概在150行左右
if ($mode =~ /[anc]/){
my $val = 0;
for my $host (@hosts){
my ($graphret,$xs,$ys) = RRDs::graph
("dummy",
'--start', $tasks[0][1],
'--end', $tasks[0][2],
# 添加下面这行
'--font TITLE:20:"WenQuanYi Zen Hei Mono"',
"DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:AVERAGE",
'PRINT:maxping:MAX:%le' );
my $ERROR = RRDs::error();
return "RRDtool did not understand your input: $ERROR." if $ERROR;
$val = $graphret->[0] if $val < $graphret->[0];
}
$val = 1e-6 if $val =~ /nan/i;
$max = { $tasks[0][1] => $val * 1.5 };
}
# 设置网页的登录用户名为smokeping,密码是自己输入的为smokeping
[root@localhost smokeping]# htpasswd -c /opt/smokeping/htdocs/htpasswd smokeping
New password: smokeping
Re-type new password: smokeping
Adding password for user smokeping
# 可以看到用户名和加密后的密码记录到该文件中了
[root@localhost smokeping]# cat /opt/smokeping/htdocs/htpasswd
smokeping:$apr1$cAduSlT.$NFgAIEKdenqs99YVNmq3e1
# 修改密码权限为root只读
[root@localhost smokeping]# chmod 600 /opt/smokeping/etc/smokeping_secrets
[root@localhost smokeping]# cat /opt/smokeping/etc/smokeping_secrets
host1:mysercert
host2:yoursercert
boomer:lkasdf93uhhfdfddf
接下来进行手动启动
[root@localhost smokeping]# bin/smokeping --logfile=/var/log/smokeping.log
ERROR: /opt/smokeping/bin/../etc/config, line 112: ERROR: FPing 'binary' does not point to an executable
# 启动失败,因为之前安装fping的路径是不一样的,需要进行修改,【如果前面已经修改过,则不用修改了】
[root@localhost smokeping]# whereis fping
fping: /usr/local/sbin/fping
[root@localhost smokeping]# vim etc/config
# 找到112行修改
# binary = /usr/sbin/fping
binary = /usr/local/sbin/fping
# 接下来启动
[root@localhost smokeping]# bin/smokeping --logfile=/var/log/smokeping.log
Note: logging to syslog as local0/info.
Daemonizing bin/smokeping ...
# 可以在日志里看到启动成功
[root@localhost smokeping]# cat /var/log/smokeping.log
Sat Nov 16 21:23:13 2019 - Smokeping version 2.007003 successfully launched.
Sat Nov 16 21:23:13 2019 - Not entering multiprocess mode for just a single probe.
Sat Nov 16 21:23:13 2019 - FPing: probing 1 targets with step 60 s and offset 20 s.
# 如果要停止smokeping进程
[root@localhost smokeping]# ps -aux | grep smoke | grep -v grep
root 34464 0.0 2.8 307688 28404 ? Ss 21:23 0:00 bin/smokeping [FPing]
[root@localhost smokeping]# ps -aux | grep smoke | grep -v grep | awk '{print $2}'
34464
# 然后使用kill -9 进程号 即可
[root@localhost smokeping]# vim /etc/systemd/system/smokeping.service
[Unit]
Description=Smokeping Network performance monitoring
After=syslog.target network.target
[Service]
ExecStart=/opt/smokeping/bin/smokeping --logfile=/var/log/smokeping.log
ExecReload=/bin/kill -HUP $MAINPID
StandardError=syslog
Type=forking
PIDFile=/opt/smokeping/var/smokeping.pid
[Install]
WantedBy=multi-user.target
# 设置完之后重启daemon
[root@localhost smokeping]# systemctl daemon-reload
# 结束之前用命令启动的smokeping,然后用systemctl去启动
[root@localhost smokeping]# kill -9 `ps -aux | grep smoke | grep -v grep | awk '{print $2}'`
[root@localhost smokeping]# ps -aux | grep smoke | grep -v grep | awk '{print $2}'
# 启动smokeping并查看状态
[root@localhost smokeping]# systemctl start smokeping
[root@localhost smokeping]# systemctl status smokeping
● smokeping.service - Smokeping Network performance monitoring
Loaded: loaded (/etc/systemd/system/smokeping.service; disabled; vendor preset: disabled)
Active: active (running) since 六 2019-11-16 21:39:44 CST; 4s ago
Process: 34597 ExecStart=/opt/smokeping/bin/smokeping --logfile=/var/log/smokeping.log (code=exited, status=0/SUCCESS)
Main PID: 34601 (/opt/smokeping/)
CGroup: /system.slice/smokeping.service
└─34601 /opt/smokeping/bin/smokeping [FPing]
# 同时查看 [root@localhost smokeping]# tail -f /var/log/smokeping.log 日志也会有相应的变化
# 创建开机自启
[root@localhost smokeping]# systemctl enable smokeping
Created symlink from /etc/systemd/system/multi-user.target.wants/smokeping.service to /etc/systemd/system/smokeping.service.
[root@localhost smokeping]# vim /etc/httpd/conf/httpd.conf
# 在下面一行之后添加以下内容
DocumentRoot "/var/www/html"
Alias /cache "/opt/smokeping/cache/"
# Alias /cropper "/opt/smokeping/htdocs/cropper/"
Alias /css "/opt/smokeping/htdocs/css/"
Alias /js "/opt/smokeping/htdocs/js/"
Alias /smokeping "/opt/smokeping/htdocs/smokeping.fcgi"
<Directory "/opt/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
Order allow,deny
Allow from all
# 密码认证
AuthName "Smokeping"
AuthType Basic
AuthUserFile /opt/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
</Directory>
# 设置完成后重启Apache服务
[root@localhost smokeping]# systemctl restart httpd
浏览器访问 http://192.168.99.101/smokeping 就需要输入刚才设置的帐密,也就是smokeping:smokeping
修改配置文件,在后面注释掉Test
段落,添加自己的节点
[root@localhost smokeping]# vim /opt/smokeping/etc/config
# 省略
*** Targets ***
probe = FPing
menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of xxx Company. \
Here you will learn all about the latency of our network.
#+ Test
#menu= Targets
##parents = owner:/Test/James location:/
#++ James
#menu = James
#title =James
#alerts = someloss
#slaves = boomer slave2
#host = james.address
#++ MultiHost
#menu = Multihost
#title = James and James as seen from Boomer
#host = /Test/James /Test/James~boomer
# 添加监测源的IP库,加入到config中,修改后重启smokeping才会生效
# 添加监控节点示例:注意+是第一层,++是第二层,+++ 是第三层
# 注释掉上面的,添加下面的监控节点
+ NetMonitor
menu = 三大网络监控
title = 监控统计
++ dianxin
menu = 电信网络监控
title = 电信网络监控列表
host = /NetMonitor/dianxin/dianxin-bj /NetMonitor/dianxin/dianxin-sc
+++ dianxin-bj
menu = 北京电信
title = 北京电信
alerts = someloss
host = 202.96.199.133
+++ dianxin-sc
menu = 四川电信
title = 四川电信
alerts = someloss
host = 61.139.2.69
++ liantong
menu = 联通网络监控
title = 联通网络监控列表
host = /NetMonitor/liantong/liantong-bj /NetMonitor/liantong/liantong-gz
+++ liantong-bj
menu = 北京联通
title = 北京联通
alerts = someloss
host = 61.135.169.121
+++ liantong-gz
menu = 广东联通
title = 广东联通
alerts = someloss
host = 221.5.88.88
++ yidong
menu = 移动网络监控
title = 移动网络监控列表
host = /NetMonitor/yidong/yidong-sc /NetMonitor/yidong/yidong-gz
+++ yidong-sc
menu = 四川移动
title = 四川移动
alerts = someloss
host = 218.201.4.3
+++ yidong-gz
menu = 广东移动
title = 广东移动
alerts = someloss
host = 211.136.192.6
注意,在host
中需要指定每一组节点信息例如host = /第一层/第二层/第三层
,否则,浏览器访问指定该名称时会报错。添加监控节点后需要重启smokeping服务
[root@localhost smokeping]# systemctl restart smokeping
但是报错啊,不过日志中这个WARNING
不影响smokeping的正常运行。
[root@localhost ~]# tail -f /var/log/smokeping.log
Sat Nov 16 22:50:36 2019 - FPing: WARNING: smokeping took 60.1801409721375 seconds to complete 1 round of polling. It should complete polling in 60 seconds. You may have unresponsive devices in your setup.
主要是页面上访问会提示创建目录失败,也就是无权限
Software error:
ERROR: creating /opt/smokeping/cache/NetMonitor: No such file or directory
解决办法是关闭Selinux
# 临时关闭
[root@localhost smokeping]# getenforce
Enforcing
[root@localhost smokeping]# setenforce 0
[root@localhost smokeping]# getenforce
Permissive
# 如果需要永久关闭 vim /etc/sysconfig/selinux ,SELINUX=enforcing 改为 SELINUX=disabled 然后重启
蜜汁问题,smokeping终于正常创建目录了,绘图也正常了
绿色线绘出的是中间值(median)的位置,一个周期内探测返回的其它值都在中间值附近被以灰度的形式显示,灰度的范围越小说明此周期内抖动较小,灰度的颜色也有深浅,颜色越深,说明RTT值在此范围相对集中,灰色区域如烟雾般笼罩在中间值附近,很契合smokeping的名称。
可以更改所有者(owner)、联系方式(contact)、邮件服务器(mailhost)、主站cgi地址(cgiurl,此选项对主从架构很重要)、syslog消息类型(syslogfacility)。同时,通过@include
字段引用了同目录下的pathnames。
*** General ***
owner = Peter Random
contact = [email protected]
mailhost = my.mail.host
sendmail = /usr/sbin/sendmail
# NOTE: do not put the Image Cache below cgi-bin
# since all files under cgi-bin will be executed ... this is not
# good for images.
imgcache = /opt/smokeping/cache
imgurl = cache
# imgurl = http://192.168.99.101/cache
datadir = /opt/smokeping/data
piddir = /opt/smokeping/var
cgiurl = http://192.168.99.101/smokeping.cgi
smokemail = /opt/smokeping/etc/smokemail.dist
tmail = /opt/smokeping/etc/tmail.dist
# specify this to get syslog logging
syslogfacility = local0
# each probe is now run in its own process
# disable this to revert to the old behaviour
# concurrentprobes = no
缺省条件下,采用sendmail邮件报警的方式,to
即接收方,from
即发送方。someloss
是预定义的一个默认检测器,检测器不仅仅是一个阈值,它可以定义一组RTT从旧到新的变化过程,pattern
的值以一个运算符开始,按照从旧到新的状态变化,示例中,>0%
表示有丢包,*12*
表示在该组中最大忽略匹配12个数值,因此这段定义的意义是:匹配一组数据是否满足丢包次数大于等于3次。
*** Alerts ***
to = [email protected]
from = [email protected]
+someloss
type = loss
# in percent
pattern = >0%,*12*,>0%,*12*,>0%
comment = loss 3 times in a row
描述rrd数据库的属性。
更改数据库配置文件无法对现有的rrd起作用,更改数据库配置文件后,需要清理现有的rrd缓存以使程序正常工作,默认rrd目录为:/opt/smokeping/data/
,也就是自己配置的data目录。step
表示基本操作间隔,即smokeping探测目标主机的间隔,默认300秒,pings
表示在一次探测动作中,发出探测包的数量,step
和 pings
的值均可以被后续的探针设置所覆盖。此配置也包含数据库归档合并的规则,共4列:合并方法、允许未知数值比例、步进,存储总行数。每一行表示一条RRA(循环归档)存储规则,预定义了多条AVERAGE
、MIN
,MAX
规则。以AVERAGE为例,第一条AVERAGE,步进1,行数1008,按照缺省step=300的条件下,表示5分钟一条,最大1008条,共存储3.5天数据,这是以此精度绘图的最大时间范围,如果超出范围,将会继续匹配合适的RRA,比如第二条AVERAGE,存储的时间范围是180天,但是精度是1小时。
*** Database ***
step = 60
pings = 60
# consfn mrhb steps total
AVERAGE 0.5 1 1008
AVERAGE 0.5 12 4360
MIN 0.5 12 4360
MAX 0.5 12 4360
AVERAGE 0.5 144 760
MAX 0.5 144 760
MIN 0.5 144 760
template 即webUI使用的网页模板,默认指向/opt/smokeping/etc/basepage.html
,模板中包含各种表单关键字。charset 即文档编码,默认使用UTF-8
*** Presentation ***
charset = utf-8
template = /opt/smokeping/etc/basepage.html
htmltitle = yes
graphborders = no
+ charts
menu = Charts
title = The most interesting destinations
++ stddev
sorter = StdDev(entries=>4)
title = Top Standard Deviation
menu = Std Deviation
format = Standard Deviation %f
++ max
sorter = Max(entries=>5)
title = Top Max Roundtrip Time
menu = by Max
format = Max Roundtrip Time %f seconds
++ loss
sorter = Loss(entries=>5)
title = Top Packet Loss
menu = Loss
format = Packets Lost %f
++ median
sorter = Median(entries=>5)
title = Top Median Roundtrip Time
menu = by Median
format = Median RTT %f seconds
# smokeping支持报表功能,允许以特定的标准对图形目标排序显示。menu 表示菜单名称,title表示显示标题。
# 在子配置项中,可以看到sorter选项,通过此选项可以制定排序器,针对RTT的统计,
# 内置了:标准差 StdDev(arg1=>val1,arg2=>val2),最大 Max(arg1=>val1,arg2=>val2),丢包率 Loss(arg1=>val1,arg2=>val2)等排序方法。
# format选项表示图例输出格式,此格式参考fprint字符串格式。
+ overview
width = 600
height = 200
range = 10h
# overview 部分,定义了概述图的外观,宽 width,高 height,
# 时间跨度 range,range的格式可以是s(seconds), m(minutes), h(hours), d(days), w(weeks), y(years)。
+ detail
width = 600
height = 600
unison_tolerance = 2
# detail部分定义了详细图的外观,宽 width,高 height,unison_tolerance 规定了统一缩放的因子,
# 此值必须参照每轮探测RTT结果的max中间值即median max,实际是为了保证图形缩放时的可读性,默认值为2,
# 表示任何最大值小于中间值“max”一半或两倍以上的图都将从统一缩放中删除。
"Last 3 Hours" 3h
"Last 30 Hours" 30h
"Last 10 Days" 10d
"Last 400 Days" 400d
# detail 也包含可定义图形时间尺度的部分,包含两列:图形时间尺度的描述和时间跨度值,此值的格式与overview部分的range格式一致。
#+ hierarchies
#++ owner
#title = Host Owner
#++ location
#title = Location
smokeping支持很多探针模块,最常用的就是内联的fping。
*** Probes ***
+ FPing
# binary = /usr/sbin/fping
binary = /usr/local/sbin/fping
在使用主从结构时,需要一个验证文件,即secrets指定的值,默认为 /opt/smokeping/etc/smokeping_secrets
,对于每一个从节点,还需要指定显示名称 display_name
,显示颜色 color(此颜色指的是概述图上的线色,非细节图),颜色代码采用RRGGBB形式。
*** Slaves ***
secrets=/opt/smokeping/etc/smokeping_secrets
+boomer
display_name=boomer
color=0000ff
+slave2
display_name=another
color=00ff00
Target是搭建snokeping主要配置的部分。menu
定义了条目的菜单名称,title
定义了条目的标题名称,host
定义了目标主机名,alerts
定义了使用的报警器,probe
定义了使用的探针,slaves
定义了需要使用的从服务器列表。同样,子条目的参数会继承父条目,也可以进行覆盖。
*** Targets ***
probe = FPing
menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of xxx Company. \
Here you will learn all about the latency of our network.
#+ Test
#menu= Targets
##parents = owner:/Test/James location:/
#++ James
#menu = James
#title =James
#alerts = someloss
#slaves = boomer slave2
#host = james.address
#++ MultiHost
#menu = Multihost
#title = James and James as seen from Boomer
#host = /Test/James /Test/James~boomer
+ NetMonitor
menu = 三大网络监控
title = 监控统计
++ dianxin
menu = 电信网络监控
title = 电信网络监控列表
host = /NetMonitor/dianxin/dianxin-bj /NetMonitor/dianxin/dianxin-sc
+++ dianxin-bj
menu = 北京电信
title = 北京电信
alerts = someloss
host = 202.96.199.133
+++ dianxin-sc
menu = 四川电信
title = 四川电信
alerts = someloss
host = 61.139.2.69
++ liantong
menu = 联通网络监控
title = 联通网络监控列表
host = /NetMonitor/liantong/liantong-bj /NetMonitor/liantong/liantong-gz
+++ liantong-bj
menu = 北京联通
title = 北京联通
alerts = someloss
host = 61.135.169.121
+++ liantong-gz
menu = 广东联通
title = 广东联通
alerts = someloss
host = 221.5.88.88
++ yidong
menu = 移动网络监控
title = 移动网络监控列表
host = /NetMonitor/yidong/yidong-sc /NetMonitor/yidong/yidong-gz
+++ yidong-sc
menu = 四川移动
title = 四川移动
alerts = someloss
host = 218.201.4.3
+++ yidong-gz
menu = 广东移动
title = 广东移动
alerts = someloss
host = 211.136.192.6
可以将监控的节点独立出来,然后使用@include xxx
指定这个文件即可。也就是可以不用在config配置文件中加上监控IP的配置,直接独立出来即可。
在config同一目录下创建一个文件
[root@localhost smokeping]# vim etc/net_test.list
# 添加
+ NetMonitor_test
menu = 三大网络监控_include
title = 监控统计
++ dianxin
menu = 电信网络监控
title = 电信网络监控列表
host = /NetMonitor_test/dianxin/dianxin-bj /NetMonitor_test/dianxin/dianxin-sc
+++ dianxin-bj
menu = 北京电信
title = 北京电信
alerts = someloss
host = 202.96.199.133
+++ dianxin-sc
menu = 四川电信
title = 四川电信
alerts = someloss
host = 61.139.2.69
++ liantong
menu = 联通网络监控
title = 联通网络监控列表
host = /NetMonitor_test/liantong/liantong-bj /NetMonitor_test/liantong/liantong-gz
+++ liantong-bj
menu = 北京联通
title = 北京联通
alerts = someloss
host = 61.135.169.121
+++ liantong-gz
menu = 广东联通
title = 广东联通
alerts = someloss
host = 221.5.88.88
++ yidong
menu = 移动网络监控
title = 移动网络监控列表
host = /NetMonitor_test/yidong/yidong-sc /NetMonitor_test/yidong/yidong-gz
+++ yidong-sc
menu = 四川移动
title = 四川移动
alerts = someloss
host = 218.201.4.3
+++ yidong-gz
menu = 广东移动
title = 广东移动
alerts = someloss
host = 211.136.192.6
修改smokeping的配置文件,在最后引入这个配置
[root@localhost smokeping]# vim etc/config
# 最后添加
@include net_test.list
[root@localhost smokeping]# systemctl restart smokeping
现在就增加了另一项。