[TOC]
1. 安装基础依赖包
安装 epel yum 源和相关基础依赖包。
yum -y install epel-release wget make gcc openssl openssl-devel rrdtool rrdtool-perl perl-core perl mod_fcgid perl-CPAN httpd httpd-devel curl bind-utils gcc make vim gcc-c++ perl-LWP-Protocol-https wqy-microhei-fonts
2. 安装fping
smokeping 2.7.2以上需要fping4.0以上
cd /data/packages
wget https://fping.org/dist/fping-4.2.tar.gz
tar -zxvf fping-4.2.tar.gz
cd fping-4.2
./configure
make
make install
3. 安装echoping
如果使用tcp ping,需要它。
cd /data/packages
wget https://fossies.org/linux/misc/old/echoping-6.0.2.tar.gz
tar -zxvf echoping-6.0.2.tar.gz
cd echoping-6.0.2
yum install -y popt-devel openssl openssl-devel
./configure --with-ssl --without-libidn
make
make install
4. 安装smokeping
源码安装 smokeping 2.7.3。
cd /data/packages
wget https://oss.oetiker.ch/smokeping/pub/smokeping-2.7.3.tar.gz
tar -zxvf smokeping-2.7.3.tar.gz
cd smokeping-2.7.3
./configure --prefix=/usr/local/smokeping
/usr/bin/gmake install
5. 配置 smokeping 和 apche
5.1 配置 smokeping
cd /usr/local/smokeping
mkdir var htdocs/{data,cache}
chown apache.apache -R /usr/local/smokeping
touch /var/log/smokeping.log
chown apache.apache /var/log/smokeping.log
cd /usr/local/smokeping/htdocs/
cp smokeping.fcgi.dist smokeping.fcgi
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
cat > /usr/local/smokeping/etc/config<10%,>10%,>10%
comment = 连续3次采样-丢包率超过10%
+lossdetect
type = loss
# in percent
pattern = ==0%,==0%,==0%,==0%,>0%,>0%,>0%
comment = 连续3次采样-存在丢包
+someloss
type = loss
# in percent
pattern = >0%,*12*,>0%,*12*,>0%
comment = 间断性丢包
+rttdetect
type = rtt
# in milli seconds
pattern = <100,<100,<100,<100,<100,<150,>150,>150,>150
comment = 连续3次采样延迟增大-超过150ms
*** 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 ***
charset = utf-8
template = /usr/local/smokeping/etc/basepage.html.dist
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
+ overview
width = 600
height = 50
range = 10h
+ detail
width = 600
height = 200
unison_tolerance = 2
"Last 3 Hours" 3h
"Last 30 Hours" 30h
"Last 10 Days" 10d
"Last 400 Days" 400d
*** Probes ***
+ FPing
binary = /usr/local/sbin/fping
#可以设置源IP地址,适用于多IP的服务器,(比如组专线内网+公网)服务器
#sourceaddressn = 1.1.1.1
#*** Slaves ***
#secrets=/usr/local/smokeping/etc/smokeping_secrets.dist
#+aliyunShenzhen
#display_name=slave1
#location=China
#color=ff0000
#
#+aliyunHangzhou
#display_name=slave2
#location=China
#color=ff00ff
*** Targets ***
probe = FPing
menu = Top
title = 网络质量监控系统
remark = 如果您是合法管理员,那么欢迎您,如果不是,请立即离开 Only legal administrators are welcome, if you are not, please leave immediately
#加载额外的监控主机(将监控主机,单独成一个文件)
@include targets
EOF
添加监控主机列表文件:
cat > /usr/local/smokeping/etc/targets<
添加 smokeping 为服务:
cat > /usr/lib/systemd/system/smokeping.service<
5.2 配置 apache
/etc/httpd/conf/httpd.conf
的行 DocumentRoot "/var/www/html"
后添加内容,如下:
DocumentRoot "/var/www/html"
Alias /smokeping "/usr/local/smokeping/htdocs/"
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthName "Smokeping"
AuthType Basic
AuthUserFile /usr/local/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
htpasswd -c /opt/smokeping/htdocs/htpasswd admin
生成 basic 验证密码。
中文支持,/usr/local/smokeping/etc/basepage.html.dist
的 head 内添加
6. 访问测试
启动 smokeping 和 apache,然后访问 http://10.10.23.103/smokeping/
systemctl daemon-reaload
systemctl start smokeping
systemctl start apache