CentOS7 源码安装 smokeping 2.7

文章目录

  • 1. 安装基础依赖包
  • 2. 安装fping
  • 3. 安装echoping
  • 4. 安装smokeping
  • 5. 配置 smokeping 和 apche
    • 5.1 配置 smokeping
    • 5.2 配置 apache
  • 6. 访问测试

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<<EOF
*** General ***
owner    = admin
contact  = [email protected]
mailhost = my.mail.host
sendmail = /usr/sbin/sendmail
imgcache = /usr/local/smokeping/htdocs/cache
imgurl   = cache
datadir  = /usr/local/smokeping/htdocs/data
piddir  = /usr/local/smokeping/var
cgiurl   = http://10.10.23.103/smokeping/smokeping.fcgi
smokemail = /usr/local/smokeping/etc/smokemail.dist
tmail = /usr/local/smokeping/etc/tmail.dist
# specify this to get syslog logging
syslogfacility = local0

*** Alerts ***
to = [email protected]
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 ***

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<<EOF
+ dns
menu = 全球公共DNS网络监控
title = 全球公共DNS网络监控
#slaves = slave1 slave2
#alerts = hostdown,hightloss

++ public-dns
menu = 公共DNS
title = 公共DNS网络监控列表
host = /dns/public-dns/dns-1 /dns/public-dns/dns-2 /dns/public-dns/dns-3 /dns/public-dns/dns-4 /dns/public-dns/dns-5 /dns/public-dns/dns-6 /dns/public-dns/dns-7 /dns/public-dns/dns-8 /dns/public-dns/dns-9 /dns/public-dns/dns-10 /dns/public-dns/dns-11 /dns/public-dns/dns-12 /dns/public-dns/dns-13 /dns/public-dns/dns-14 /dns/public-dns/dns-15 /dns/public-dns/dns-16 /dns/public-dns/dns-17 /dns/public-dns/dns-18 /dns/public-dns/dns-19 /dns/public-dns/dns-20 /dns/public-dns/dns-21 /dns/public-dns/dns-22 /dns/public-dns/dns-23 /dns/public-dns/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

添加 smokeping 为服务:

cat > /usr/lib/systemd/system/smokeping.service<<EOF
[Unit]
Description=Latency Logging and Graphing System
After=syslog.target network.target

[Service]
#ExecStart=/usr/sbin/smokeping --nodaemon  # 2.6 yum install
ExecStart=/usr/local/smokeping/bin/smokeping --nodaemon  --config=/usr/local/smokeping/etc/config --logfile=/var/log/smokeping.log # 2.7 src install
ExecReload=/bin/kill -HUP $MAINPID
StandardError=syslog

[Install]
WantedBy=multi-user.target
EOF

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

你可能感兴趣的:(运维/开发,centos,smokeping)