新版本的改动点:
1:data cache var 要放到htdocs目录下
文章目录
安装必要的软件
#系统环境centos7(fping这个软件在epel源里面)
yum -y install epel* wget make gcc openssl openssl-devel rrdtool rrdtool-perl perl-core perl mod_fcgid perl-CPAN httpd httpd-devel
yum -y install fping
下载软件smokeping
mkdir /opt/smokeping
#wget https://oss.oetiker.ch/smokeping/pub/smokeping-2.7.2.tar.gz
wget https://qiniu.wsfnk.com/smokeping-2.7.2.tar.gz
tar xf smokeping-2.7.2.tar.gz -C /opt/
cd /opt/smokeping-2.7.2
./configure --prefix=/opt/smokeping
/usr/bin/gmake install
#第一次make,是不会成功的,需要再次执行一次
/usr/bin/gmake install
cd /opt/smokeping/
mkdir /opt/smokeping/htdocs/{data,cache,var}
touch /var/log/smokeping.log
cd /opt/smokeping/htdocs/
mv smokeping.fcgi.dist smokeping.fcgi
cd /opt/smokeping/etc
mv config.dist config
设置smokeping的整体配置
cat > /opt/smokeping/etc/config << EOF
*** General ***
owner = Peter Random
contact = some@address.nowhere
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 = smokealert@company.xy
+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/sbin/fping
#可以设置源IP地址,适用于多IP的服务器,(比如组专线内网+公网)服务器
#sourceaddressn = 1.1.1.1
*** Slaves ***
secrets=/opt/smokeping/etc/smokeping_secrets.dist
+aliyun
display_name=阿里印度孟买slave
location=India
color=ff0000
+SH_youfu_CT_Proxy
display_name=上海有孚电信(双线)slave
location=China
color=ff00ff
+template
display_name=陕西联通slave
location=China
color=31b404
*** Targets ***
probe = FPing
menu = Top
title = 网络质量监控系统
remark = 如果您是合法管理员,那么欢迎您,如果不是,请立即离开 \
Only legal administrators are welcome, if you are not, please leave immediately
#加载额外的监控主机(将监控主机,单独成一个文件)
@include targets
EOF
为smokeping创建一个单独的监控主机文件
touch /opt/smokeping/etc/targets
cat > /opt/smokeping/etc/targets << EOF
+ DNS
menu = 全球公共DNS网络监控
title = 全球公共DNS网络监控
slaves = aliyun template SH_youfu_CT_Proxy
#alerts = hostdown,hightloss
++ gg
menu = 公共DNS(绘图压力大-勿点击)
title = 公共DNS网络监控列表
host = /DNS/gg/dns-1 /DNS/gg/dns-2 /DNS/gg/dns-3 /DNS/gg/dns-4 /DNS/gg/dns-5 /DNS/gg/dns-6 /DNS/gg/dns-7 /DNS/gg/dns-8 /DNS/gg/dns-9 /DNS/gg/dns-10 /DNS/gg/dns-11 /DNS/gg/dns-12 /DNS/gg/dns-13 /DNS/gg/dns-14 /DNS/gg/dns-15 /DNS/gg/dns-16 /DNS/gg/dns-17 /DNS/gg/dns-18 /DNS/gg/dns-19 /DNS/gg/dns-20 /DNS/gg/dns-21 /DNS/gg/dns-22 /DNS/gg/dns-23 /DNS/gg/dns-24
+++ dns-1
menu = 江西移动-211.141.90.68
title = 江西移动-211.141.90.68
host = 211.141.90.68
+++ dns-2
menu = 江西电信-202.101.224.68
title = 江西电信-202.101.224.68
host = 202.101.224.68
+++ dns-3
menu = 江西联通-220.248.192.12
title = 江西联通-220.248.192.12
host = 220.248.192.12
+++ dns-4
menu = 114-DNS-114.114.114.114
title = 114-DNS-114.114.114.114
host = 114.114.114.114
+++ dns-5
menu = 114安全版-114.114.114.119
title = 114安全版-114.114.114.119
host = 114.114.114.119
+++ dns-6
menu = 阿里-223.5.5.5
title = 阿里-223.5.5.5
host = 223.5.5.5
+++ dns-7
menu = 百度-180.76.76.76
title = 百度-180.76.76.76
host = 180.76.76.76
+++ dns-8
menu = DNSPOD-119.29.29.29
title = DNSPOD-119.29.29.29
host = 119.29.29.29
+++ dns-9
menu = CNNIC-1.2.4.8
title = CNNIC-1.2.4.8
host = 1.2.4.8
+++ dns-10
menu = DNS派-218.30.118.6
title = DNS派-218.30.118.6
host = 218.30.118.6
+++ dns-11
menu = 谷歌-8.8.8.8
title = 谷歌-8.8.8.8
host = 8.8.8.8
+++ dns-12
menu = IBMQ9-9.9.9.9
title = IBMQ9-9.9.9.9
host = 9.9.9.9
+++ dns-13
menu = CF-1.1.1.1
title = CF-1.1.1.1
host = 1.1.1.1
+++ dns-14
menu = 科莫多-8.26.56.26
title = 科莫多-8.26.56.26
host = 8.26.56.26
+++ dns-15
menu = GTEI-4.2.2.1
title = GTEI-4.2.2.1
host = 4.2.2.1
+++ dns-16
menu = PCCW-205.252.144.228
title = PCCW-205.252.144.228
host = 205.252.144.228
+++ dns-17
menu = HKIX-202.181.224.2
title = HKIX-202.181.224.2
host = 202.181.224.2
+++ dns-18
menu = 澳门-202.175.3.8
title = 澳门-202.175.3.8
host = 202.175.3.8
+++ dns-19
menu = 中华电信-168.95.192.1
title = 中华电信-168.95.192.1
host = 168.95.192.1
+++ dns-20
menu = 英国-193.0.14.129
title = 英国-193.0.14.129
host = 193.0.14.129
+++ dns-21
menu = 日本-202.12.27.33
title = 日本-202.12.27.33
host = 202.12.27.33
+++ dns-22
menu = 韩国-164.124.101.31
title = 韩国-164.124.101.31
host = 164.124.101.31
+++ dns-23
menu = 洛杉矶hostspace-162.212.181.53
title = 洛杉矶hostspace-162.212.181.53
host = 162.212.181.53
+++ dns-24
menu = 洛杉矶hostspace-1-192.126.112.53
title = 洛杉矶hostspace-2-192.126.112.53
host = 192.126.112.53
EOF
配置httpd,这里采用虚拟主机的方式配置
touch /etc/httpd/conf.d/vhost.conf
cat > /etc/httpd/conf.d/vhost.conf << EOF
DocumentRoot /opt/smokeping
<directory "="" opt="" smokeping="" htdocs"="">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
AllowOverride AuthConfig
Order allow,deny
#Require all granted
#指定不用权限认证的salve节点
Require ip 113.2.2.2
Allow from all
AuthName "Smokeping"
AuthType Basic
AuthUserFile /opt/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
</directory>
EOF
正确的设置相关访问权限
chown apache. /opt/smokeping/htdocs/{data,cache,var} -R
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
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
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://ip/htdocs/smokeping.fcgi
主从配置时,从节点的启动命令行
/opt/smokeping/bin/smokeping --master-url=http://jk.wsfnk.com:35966/htdocs/smokeping.fcgi --cache-dir=/opt/smokeping/htdocs/cache --shared-secret=/opt/smokeping/etc/slave_secrets --logfile=/tmp/slave.log
如果文章对你有帮助,欢迎点击上方按钮打赏作者
暂无评论