先把官网挪腾出来
https://oss.oetiker.ch/smokeping/
然后拷贝一些介绍过来
Smokeping是一款用于网络性能监测的开源监控软件,主要用于对IDC的网络状况,网络质量,稳定性等做检测,通过rrdtool制图方式,图形化地展示网络的时延情况,进而能够清楚的判断出网络的即时通信情况。
SmokePing的特点
SmokePing keeps track of your network latency:
Best of breed latency visualisation.(最佳图形展示功能,延时丢包等可以很直观的可视化展现)
Interactive graph explorer.(交互式浏览器图表)
Wide range of latency measurement 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
然后蛮,看一下他的运行机制,根据我的理解画的,有异常指出来进行修改
1.首先是单节点的somkeping的运行机制
2.然后是多节点的运行机制
然后看一下部署
部署环境是CentOS7.2
安装过程比较简单,首先要配置好yum
单节点安装或单点运行
#!/bin/bash
yum -y install perl-Sys-Syslog libidn-devel perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker perl-RRD-Simple rrdtool rrdtool-perl curl fping echoping httpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi
mkdir -p /tmp/smokeping
cd /tmp/smokeping
wget echoping-6.0.2.tar.gz
wget fping-3.10.tar.gz
wget smokeping-2.6.9.tar.gz
相关的几个软件包我放在GitHub上了
https://github.com/776948741/software/tree/master/smokeping
tar xvf echoping-6.0.2.tar.gz
tar xvf fping-3.10.tar.gz
tar xvf smokeping-2.6.9.tar.gz
cd echoping-6.0.2 && ./configure && make && make install
cd ../
cd fping-3.10 && ./configure && make && make install
cd ../
cd smokeping-2.6.9 && ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty && ./configure --prefix=/usr/local/smokeping && /bin/gmake install
/bin/gmake install
cd /usr/local/smokeping/
mkdir cache data var
touch /var/log/smokeping.log
chown apache:apache cache data var
chown apache:apache /var/log/smokeping.log
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
cd /usr/local/smokeping/htdocs
mv smokeping.fcgi.dist smokeping.fcgi
cd /usr/local/smokeping/etc
mv config.dist config
部署好后,看看都有哪些配置文件吧
[root@smokeping-01 etc]# pwd
/usr/local/smokeping/etc
[root@smokeping-01 etc]# ll
total 32
-rwxr-xr-x 1 ljp ljp 2041 Jul 3 12:26 basepage.html.dist 本次配置没用到
-rwxr-xr-x
1 ljp ljp 4981 Jul 6 18:47 config 主配置文件,里面包含了告警方式、绘图控制、时间展示控制、告警策略、监控频率、主从配置、被监控主机配置
drwxr-xr-x 2 ljp ljp 4096 Jul 3 12:26 examples 没用到,不大清楚
-rwxr-xr-x 1 ljp ljp 1563 Jul 3 12:26 smokemail.dist 采用独立脚本的方式发送邮件,本次配置没用到
-rw------- 1 ljp ljp 320 Jul 3 17:11 smokeping_secrets.dist 配置从主机的列表配置格式为"从主机名:密码"
-rwxr-xr-x 1 ljp ljp 3815 Jul 3 12:26 tmail.dist 没用到,不大清楚
[root@smokeping-01 etc]#
配置文件
cat /usr/local/smokeping/etc/config
*** General ***
owner = Peter Random
#contact = [email protected]
#mailhost = mail.xxxx.com
#mailuser = [email protected]
#mailpwd = xxxxxxxx
#sendmail = /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 = /usr/local/smokeping/cache
imgurl = cache
datadir = /usr/local/smokeping/data
piddir = /usr/local/smokeping/var
cgiurl = http://x.x.x.x/smokeping.cgi #写本机的IP地址
#-------------------------------------
#smokemail = /usr/local/smokeping/etc/smokemail.dist
#tmail = /usr/local/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
#--------------------------------------------
#告警的方式,当有告警的时候可以将告警的消息发送给脚本,脚本进行处理,后边我把脚本贴一下,这块我们是用的钉钉
*** Alerts ***
to = |/usr/local/smokeping/bin/send_alert.sh
#--------------------------------------------
#--------------------------------------------
#告警策略定制,具体的信息翻翻官方文档吧rttloss是当延时大于200ms的时候预警,someloss是丢包的时候预警
+rttloss
type = rtt
# in percent
pattern = >200,>200
comment = ping rtt greater than 200ms!
+someloss
type = loss
# in percent
pattern = >80%,*12*,>80%
comment = loss 3 times in a row
#--------------------------------------------
*** Database ***
step = 60
pings = 20
# 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.dist
+ 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 = 800
height = 150
range = 24h
+ detail
width = 1200
height = 400
unison_tolerance = 2
"Last 24 Hours" 24h
"Last 3 Days" 3d
"Last 7 Days" 7d
"Last 30 Days" 30d
"Last 1 Years" 1y
#+ hierarchies
#++ owner
#title = Host Owner
#++ location
#title = Location
*** Probes ***
+ FPing
binary = /usr/sbin/fping
#--------------------------------------------
#从主机列表(多slave的时候配置)
*** Slaves ***
#这个文件注意权限配置为600
secrets=/usr/local/smokeping/etc/smokeping_secrets.dist
#--------------------------------------------
#--------------------------------------------
#从主机采集后的数据展示配置(多slave的时候配置)
+test1.bj
display_name=test1.bj
color=cc0066
+test2.tj
display_name=test2.tj
color=ff0033
+test3.sh
display_name=test3.sh
color=663300
#--------------------------------------------
*** 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.
#--------------------------------------------
#接收哪些从服务器采集的数据(多slave的时候配置)
slaves = test1.bj test2.tj test3.sh
#使用哪些告警策略匹配(此处是默认配置,下方配置的主机均应用该配置,如果主机中指定了alerts则使用主机自己的告警配置项)
alerts = someloss,rttloss
#--------------------------------------------
#--------------------------------------------
#监控树配置
+ddcINFO
menu= INFO
title = INFO
#第一个被监控主机
++ bj01_1
menu = bj01_1_192.168.1.1
title = bj01_1_192.168.1.1
host = 192.168.1.1
#第二个被监控主机
++ tj01_2
menu = tj01_2_192.168.2.1
title = tj01_2_192.168.2.1
host = 192.168.2.1
#第...
++ sh01_1
menu = sh01_1_192.168.3.1
title = sh01_1_192.168.3.1
host = 192.168.3.1
#--------------------------------------------
告警脚本
title="smokeping告警!!!"
alertName="告警规则:$1"
monitorInfo="监控项:`echo $2|awk '{print $1}'|awk -F "." '{print $2}'`"
monitorFrom=`echo $2|awk '{print $3}'|awk -F "]" '{print $1}'`
[ -z "$monitorFrom" ] && monitorFrom="控制节点"
monitorFrom="监测点:${monitorFrom}"
lossInfo="丢包率信息:`echo $3|awk -F ":" '{print $2}' |awk -F "," '{print $NF}'|awk '{print $1}'`"
rttInfo="延时信息:`echo $4|awk -F ":" '{print $2}' |awk -F "," '{print $NF}'|awk '{print $1}'`"
ipAddr="异常IP地址:$5\n"
curl -XPOST -H 'Content-Type':'application/json' '钉钉机器人接口URL' -d '{"msgtype": "text", "text": {"content": "'${title}'\n'${alertName}'\n'${monitorInfo}'\n'${monitorFrom}'\n'${lossInfo}'\n'${rttInfo}'\n'${ipAddr}'"}, "at": {"atMobiles": ["156xxxx8827", "189xxxx8325"], "isAtAll": false}}'
echo "${alertName}
${monitorInfo}
${monitorFrom}
${lossInfo}
${rttInfo}
${ipAddr}" | mutt -s "${title}" [email protected]
客户端服务器信息配置(多slave的时候配置)
#注意域名解析或者hosts记录
cat /usr/local/smokeping/etc/smokeping_secrets.dist
test1.bj:mima
test2.tj:mima
test3.sh:mima
配置好后就可以启动服务了
启动
./smokeping --debug-daemon --logfile=/var/log/smokeping.log
以上的是服务器端的部署
下面看看客户端的部署
多点安装,slave的安装过程
#!/bin/bash
yum -y install perl-Sys-Syslog libidn-devel perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker perl-RRD-Simple rrdtool rrdtool-perl curl fping echoping httpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi
mkdir -p /tmp/smokeping
cd /tmp/smokeping
wget echoping-6.0.2.tar.gz
wget fping-3.10.tar.gz
wget smokeping-2.6.9.tar.gz
wget start.sh ##启动方式
相关的几个软件包我放在GitHub上了
https://github.com/776948741/software/tree/master/smokeping
tar xvf echoping-6.0.2.tar.gz
tar xvf fping-3.10.tar.gz
tar xvf smokeping-2.6.9.tar.gz
cd echoping-6.0.2 && ./configure && make && make install
cd ../
cd fping-3.10 && ./configure && make && make install
cd ../
cd smokeping-2.6.9 && ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty && ./configure --prefix=/usr/local/smokeping && /bin/gmake install
/bin/gmake install
cd ../
echo "mima" >/usr/local/smokeping/etc/slave_secret.txt
chmod 600 /usr/local/smokeping/etc/slave_secret.txt
cd /usr/local/smokeping/
mkdir cache data var
touch /var/log/smokeping.log
chown apache:apache cache data var
chown apache:apache /var/log/smokeping.log
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
cd /usr/local/smokeping/htdocs
mv smokeping.fcgi.dist smokeping.fcgi
cd /usr/local/smokeping/etc
mv config.dist config
cd /usr/local/smokeping/bin/
wget start.sh ##https://github.com/776948741/software/blob/master/smokeping/start.sh
#脚本中是客户端的启动方式,需要修改一下指向主服务器
chmod +x start.sh
sh start.sh
#start.sh 脚本
name=`hostname`
/usr/local/smokeping/bin/smokeping --master-url=http://x.x.x.x/smokeping/smokeping.fcgi --cache-dir=/usr/local/smokeping/cache/ --shared-secret=/usr/local/smokeping/etc/slave_secret.txt --slave-name=${name}