安装依赖包
yum -y install epel* wget make gcc httpd httpd-devel popt-devel \
openssl openssl-devel rrdtool rrdtool-perl perl-core perl-CPAN \
curl libxml2-devel libpng-devel glib pango pango-devel \
freetype freetype-devel fontconfig cairo cairo-devel \
libart_lgpl libart_lgpl-devel perl-Sys-Syslog podofo \
mod_fcgid bind-utils 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 php-pear-XML-RSS
解压并编译软件包
cd /usr/local/src
tar -xvf fping-4.2.tar.gz && tar -xvf echoping-6.0.2.tar.gz && tar -xvf smokeping-2.7.3.tar.gz
cd /usr/local/src/fping-4.2
./configure && make && make install
cd /usr/local/src/echoping-6.0.2
./configure --with-ssl --without-libidn
make && make install
cd /usr/local/src/smokeping-2.7.3
./configure --prefix=/opt/smokeping PERL5LIB=/usr/lib64/perl5/
/usr/bin/gmake install
修改配置文件
cd /opt/smokeping/
mkdir /opt/smokeping/htdocs/{data,cache,var}
touch /var/log/smokeping.log
cd /opt/smokeping/htdocs/
cp smokeping.fcgi.dist smokeping.fcgi
cd /opt/smokeping/etc
cp config.dist config
修改主配置文件
cat > /opt/smokeping/etc/config << EOF
*** General ***
owner = Peter Random
contact = [email protected]
mailhost = my.mail.host
sendmail = /sbin/sendmail
imgcache = /opt/smokeping/htdocs/cache
imgurl = cache
datadir = /opt/smokeping/htdocs/data
piddir = /opt/smokeping/htdocs/var
cgiurl = http://192.168.2.250/smokeping.cgi
smokemail = /opt/smokeping/etc/smokemail.dist
tmail = /opt/smokeping/etc/tmail.dist
# specify this to get syslog logging
syslogfacility = local0
*** Alerts ***
to = |/opt/smokeping/bin/mailx_alert.sh
from = [email protected]
+hostdown
type = loss
# in percent
pattern = ==0%,==0%,==0%,==U
comment = 对端无响应
+hightloss
type = loss
# in percent
pattern = ==0%,==0%,==0%,==0%,>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 ***
template = /opt/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
*** Targets ***
probe = FPing
menu = Top
title = 网络质量监控系统
remark = 仅欢迎合法的管理员,如果不是,请立即离开 \
Only legal administrators are welcome, if you are not, please leave immediately
#加载额外的监控主机(将监控主机,单独成一个文件)
@include targets
EOF
添加单一监控列表
cat > /opt/smokeping/etc/targets << EOF
+ GP
menu = GreenPlum集群监控
title = GreenPlum集群监控
#alerts = hostdown,hightloss
++ cluster
menu = GreenPlum集群监控
title = GP集群监控列表
host = /GP/cluster/node-11 /GP/cluster/node-12 /GP/cluster/node-13 /GP/cluster/node-14 /GP/cluster/node-15 /GP/cluster/node-16 /GP/cluster/node-17
+++ node-11
menu = gpmdw-209.11
title = gpmdw-209.11
host = 192.168.209.11
+++ node-12
menu = gpsdw1-209.12
title = gpsdw1-209.12
host = 192.168.209.12
+++ node-13
menu = gpsdw2-209.13
title = gpsdw2-209.13
host = 192.168.209.13
+++ node-14
menu = gpsdw3-209.14
title = gpsdw3-209.14
host = 192.168.209.14
+++ node-15
menu = gpsdw4-209.15
title = gpsdw4-209.15
host = 192.168.209.15
+++ node-16
menu = gpsdw5-209.16
title = gpsdw5-209.16
host = 192.168.209.16
+++ node-17
menu = gpsdw6-209.17
title = gpsdw6-209.17
host = 192.168.209.17
+ DNS
menu = 公共DNS网络监控
title = 公共DNS网络监控
#alerts = hostdown,hightloss
++ public
menu = 公共DNS监控
title = 公共DNS网络监控列表
host = /DNS/public/dns-1 /DNS/public/dns-2 /DNS/public/dns-3 /DNS/public/dns-4
+++ dns-1
menu = 114-DNS-114.114.114.114
title = 114-DNS-114.114.114.114
host = 114.114.114.114
+++ dns-2
menu = 阿里-223.5.5.5
title = 阿里-223.5.5.5
host = 223.5.5.5
+++ dns-3
menu = 百度-180.76.76.76
title = 百度-180.76.76.76
host = 180.76.76.76
+++ dns-4
menu = 腾讯-119.29.29.29
title = 腾讯-119.29.29.29
host = 119.29.29.29
EOF
配置httpd虚拟主机
cat > /etc/httpd/conf.d/smokeping.conf << EOF
DocumentRoot /opt/smokeping
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
AllowOverride AuthConfig
Order allow,deny
#Require all granted
#指定不用权限认证的salve节点
Require ip 10.112
Allow from all
AuthName "Smokeping"
AuthType Basic
AuthUserFile /opt/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
EOF
设置访问权限
chown -R apache. /opt/smokeping/htdocs/{data,cache,var}
chown apache. /var/log/smokeping.log
chmod 600 /opt/smokeping/etc/smokeping_secrets.dist
htpasswd -c /opt/smokeping/htdocs/htpasswd admin
安装中文支持,字体
yum install -y wqy-microhei-fonts.noarch
启动服务
systemctl start httpd
启动smokeping
/opt/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &
设置开机启动
echo "/opt/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local
chmod +x /etc/rc.d/rc.local
smokeping服务管理
/opt/smokeping/bin/smokeping --reload # 重载配置
/opt/smokeping/bin/smokeping --restart # 重启
访问地址如下
http://192.168.203.90/htdocs/