1 什么是smokeping
2 smokeping架构组成3 smokeping分布式介绍
4 如何看懂smokeping图表
5 如何判断一个节点的好坏
Smokeping是rrdtool的作者TobiOetiker 的作品,是用Perl 写的,主要是监视网络性能,包括常规的ping,用echoping 监www 服务器性能,监视dns 查询性能,监视ssh 性能等。底层也是rrdtool做支持,特点是画的图非常亮,网络丢包和延迟用颜色和阴影来表示。
Smokeping由以下组件组成:
RRDtool、Fping、Echoping、Curl、Dig、SSh、Perl 模块,
Perl、SpeedyCGI、ApacheORNGINX
使用Smokeping的过程中,很容易就发现,如果从单个节点去探测网络性能,往往是不够的,Smokeping提供了多节点的分布式部署功能,也就是可以从多个节点去探测到某个地区的网络状态,这样才是我们监控网络希望看到的情况。
Smokeping称其为主从模式,主从模式的配置很简单,从服务器的安装和主服务器相同,只是从服务器不用自己的config文件,而是在启动的过程中请求主服务器的config文件,这样你只需要维护主服务器上的配置文件即可。
Smokeping检测分布式的检测方式是被动模式,由从节点启动时获得主节点的config文件,然后进行测试,测试完毕后直接将数据提交给主节点。主从通信验证是通过我们可以设置多个从服务器,主从服务器通过指定--shared-secret=filename来和主进行密码验证。
X轴表示时间轴
Y轴表示ping的时间值
3.6ms表示 Ping质量测试的响应速度平均值
中间红线能看出网络是否有抖动
直线表示稳定,有频繁曲线表示网络抖动;如果是阴影表示有网络小幅度抖动
ls字段表示Ping质量测试的丢包率
根据网络抖动判断,抖动范围超过10ms的都属于网络不稳定我们要每天观察是否都有规律的网络抖动现象
根据丢包状况判断:
刚进入详细报告后,看总曲线的颜色,根据20个测试数据包返回的数据判断
绿色表示0丢包.属于最好.浅蓝色1个丢包,深蓝色2个丢包….以此类推
从这个报告图里可以看出:
1.曲线都是绿色的0丢包或偶尔一两个丢包算合格
2.曲线无抖动,阴影不明显或偶尔有抖动的算合格(包裹阴影部分)
3.Ping值小于30ms如果小于50ms还算合格
smokeping搭建
1服务端安装
可分多种web框架可选nginx apache等 接口可选fsgi cgi
1)apache安装略
httpd.conf中directory字段加入
#Options FollowSymLinks ExecCGI
Options Indexes FollowSymLinks
Options ExecCGI
#AllowOverride None
#Order allow,deny
#Allow from all
Alias /smokeping "/usr/local/smokeping/"
AllowOverride None
AddHandler cgi-script cgi
Options ExecCGI
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
DirectoryIndex smokeping.cgi
1).rrdtool.FPing.EchoPing.Curl.dig.SSH
wget http://sourceforge.net/projects/echoping/files/echoping/6.0.2/echoping-6.0.2.tar.gz/download
wget http://fping.sourceforge.net/download/fping.tar.gz
wget http://dag.wieers.com/rpm/packages/echoping/echoping-5.2.0-1.2.el5.rf.x86_64.rpm
wget http://dag.wieers.com/rpm/packages/fping/fping-2.4-1.b2.2.el5.rf.x86_64.rpm
rpm -ivh *ping*x86_64.rpm
yum install -y freetype freetype-devel libpng libpng-devel gd gd-devel pango pango-devel libxml2 libxml2-devel libart_lgpl libart_lgpl-devel perl-libwww-perl perl-IO-Socket-SSL perl-Net-Telnet perl-Socket6 perl-Net-DNS perl-LDAP
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.5.tar.gz
tar zvxf rrdtool-1.4.5.tar.gz && cd rrdtool-1.4.5
sed -i 's/setlocale(LC_NUMERIC, "C")/setlocale(LC_NUMERIC, "zh_CN.UTF-8")/g' src/rrd_graph.c
./configure --prefix=/usr/local/rrdtool --enable-perl-site-install --with-perl-options &&make &&make install
perl -MRRDs -le 'print q(ok!)' 查看RRDs.pm 提示加载libdbi.so.o加载不上,安装yum install libdbi
2).perl(Perl 5.8.8)的模块支持
#perl -MCPAN -e -shell
#install FCGI,CGI,CGI::Fast,Config::Grammar,Digest::HMAC_MD5,Net::Telnet,Net::OpenSSH,Net::SNMP,Net::LDAP,Net::DNS, IO::Pty,LWP,Socket6,IO::Socket::SSL
perl -MCPAN -e 'install FCGI,CGI,CGI::Fast,Config::Grammar,Digest::HMAC_MD5,Net::Telnet,Net::OpenSSH,Net::SNMP,Net::LDAP,Net::DNS, IO::Pty,LWP,Socket6,IO::Socket::SSL'
3).smokeping安装
export PERL5LIB=/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/ #64位系统
export PERL5LIB=/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/ #32位系统
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.6.tar.gz
tar zvxf smokeping-2.6.6.tar.gz && cd smokeping-2.6.6
./configure --prefix=/usr/local/smokeping &&make &&make install
########################分割线###############################################
smokeping config中需要配置的项和优化
*** General ***
owner = www.funshion.com
contact = [email protected]
mailhost = mail.funshion.com
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 p_w_picpaths.
imgcache = /usr/local/smokeping/cache
imgurl = http://192.168.x.x/smokeping/cache
datadir = /usr/local/smokeping/data
piddir = /usr/local/smokeping/var
cgiurl = http://192.168.x.x/smokeping/htdocs/smokeping.cgi
smokemail = /usr/local/smokeping/etc/smokemail
tmail = /usr/local/smokeping/etc/tmail
# 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 = yes
*** Alerts ***
to = [email protected]
from = [email protected]
+someloss
type = loss
# in percent
pattern = >3%,*12*,>3%,*12*,>3%
comment = detected loss 3 times over the last two hours
+highloss
type = loss
# in percent
pattern = >50%,*12*,>50%,*12*,>50%
comment = detected loss 3 times over the last two hours
+rttdetect
type = rtt
# in milliseconds
pattern = <100,<100,<100,<100,<100,>100,>100,>100,>100
comment = routing messed up again ?
+highrttdetect
type = rtt
# in milliseconds
pattern = <20,<20,<20,<20,<20,>20,>20,>20,>20
comment = routing messed up again ?
*** Database ***
step = 300
pings = 100
# consfn mrhb steps total
AVERAGE 0.5 1 1008
AVERAGE 0.5 12 4320
MIN 0.5 12 4320
MAX 0.5 12 4320
AVERAGE 0.5 144 720
MAX 0.5 144 720
MIN 0.5 144 720
*** Presentation ***
template = /usr/local/smokeping/etc/basepage.html
charset = utf-8
+ 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
+ overview
width = 600
height = 100
range = 12h
+ detail
width = 600
height = 200
#loss_background = yes
unison_tolerance = 2
"最后1天" 1d
"最后1周" 7d
"最后1个月" 30d
++loss_colors
0 00ff00 "0"
1 00b8ff "1/100"
2 0059ff "2/100"
3 5e00ff "3/100"
4 7e00ef "4/100"
5 ffff00 "5/100"
10 ff00ff "10/100"
50 ff0000 "50/100"
#99 ff0000 "99/100"
#+ hierarchies
#++ owner
#title = Host Owner
#++ location
#title = Location
*** Probes ***
+ FPing
binary = /usr/sbin/fping
*** Slaves ***
secrets=/usr/local/smokeping/etc/secrets
+zhengzhoucnc
display_name=郑州联通
color=b0e0e6
*** Targets ***
probe = FPing
menu = Top
title = www.funshion.com
remark = 欢迎使用smokeping监控
menuextra = *
+ CNC-OTHER-NODE
menu = 联通NODE
title = 联通NODE
nomasterpoll = yes
++ zhengzhou
menu = 郑州联通
title = 郑州联通
alerts = someloss,rttdetect
slaves = beijingcnc
host = 182.118.x.x
+++ zhengzhou
menu = 郑州联通
title = 郑州联通
alerts =
slaves = huhehaotecnc shenyangcnc taiyuancnc tianjincnc guangzhoucnc shijiazhuangcnc
host = 182.118.x.x
+ Test
menu = 测试
title = 测试
nomasterpoll = yes
++ TW
menu = 台湾
title = 台湾
alerts =
slaves = beijingcnc yizhuangctc-waiwang nanningctc nanchangctc
host = 60.199.217.26
1 此处定义节点由于较多所以只写了一个郑州
2 此配置文件针对监控优先级报警 采用了3层目录形式 可针对自己想监控的节点进行报警,极大降 低了误报
3 Alerts定义多种规则,针对不通网络质量采用不通阀值
当然smokeping也支持如RTX 飞信等报警 需要手工写一些脚本或添加相应程序实现
1 smokeping.cgi 放置在 htdocs下
#!/bin/sh
#export PERL5LIB=/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/
exec /usr/local/smokeping/bin/smokeping_cgi /usr/local/smokeping/etc/config
让smokeping_cgi读取配置文件执行
2 smokeping生成的cache图片按照定义时间来定义 last_ 后面的数值
3 必须刷新url才可生成cache图片,可定期使用脚本刷新
4 secrets文件权限600
5 smokeping服务端启动脚本
killall -9 smokeping
/usr/local/smokeping/bin/smokeping --config=/usr/local/smokeping/etc/config --logfile=/usr/local/smokeping/htdocs/var/smokeping.log
6 smokeping客户端启动脚本
#!/bin/bash
MASTERURL=http://xxx.xx.xx.xx/htdocs/smokeping.cgi
SLAVENAME=
CACHEDIR=/usr/local/smokeping/cache
PIDFILE=$CACHEDIR/smokeping.pid
SECRET=/usr/local/smokeping/etc/secrets
LOGFILE=/usr/local/smokeping/var/smoke.log
RUNNING=0
if [ -f $PIDFILE ] ; then
PID=`cat $PIDFILE`
if kill -0 $PID 2>/dev/null ; then
echo "smokeping is running with PID $PID"
exit 0
else
echo "smokeping not running but PID file exists => delete PID file"
rm -f $PIDFILE
fi
else
echo "smokeping (no pid file) not running"
fi
if
/usr/local/smokeping/bin/smokeping --master-url=$MASTERURL --slave-name=$SLAVENAME --cache-dir=$CACHEDIR --shared-secret=$SECRET --logfile=$LOGFILE > /dev/null; then
echo "smokeping started"
else
echo "smokeping could not be started"
fi
欢迎大家交流或给我留言