IDC网络质量分析工具之(一)smokeping的安装与配置

系统及环境介绍

系统环境:centos7.3安装epel源
介绍:smokeping是一款开源网络测试工具,广泛应用于机房网络质量分析

第一:调整系统时间,安装一些列相关工具

需要安装 fping,httpd,gmake,gcc,rrdtool,以及相关perl组件

#调整系统时间
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

yum -y install 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 screen mod_fcgid perl-CGI perl-Config-Grammar perl-SNMP_Session perl-Sys-Syslog

#若也可以尝试yum 安装smokeping,然后再卸载

第二:去官方网站下载最新版本的smokeping,并解压,安装

#A:下载最新版本smokeping源码
    wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz

#B:解压源码到指定目录
    mkdir /opt/smokeping 
    tar xzf smokeping-2.6.11.tar.gz -C /opt

#C:编译并安装到指定目录/opt/smokeping
    cd /opt/smokeping-2.6.11
    ./configure --prefix=/opt/smokeping   #若是出错,请先运行下一条命令,再编译
    ./setup/build-perl-modules.sh /opt/smokeping/thirdparty
    ./configure --prefix=/opt/smokeping
    /usr/bin/gmake install

#D:创建smokeping工作必要的日志文件,及目录,并授权
    cd /opt/smokeping
    mkdir cache data var
    touch /var/log/smokeping.log
    chown apache:apache cache data var
    chown apache:apache /var/log/smokeping.log

#E:修改smokeping的配置文件,实现web界面显示中文
    cd /opt/smokeping/htdocs/
    mv smokeping.fcgi.dist smokeping.fcgi
    cd /opt/smokeping/etc
    mv config.dist config
    vim /opt/smokeping/etc/config

cgiurl   = http://some.url/smokeping.cgi #第一处:把some.url修改为你的ip或者域名
step     = 300      #第二处:从300改为60,表示60秒ping20次
*** Presentation ***
charset = utf-8 #第三处:Presentatio项下,添加这一行,表示web界面展示支持中文字符

#F:修改安全文件权限
    chmod 600 /opt/smokeping/etc/smokeping_secrets.dist   #注意:此文件权限须是600

第三:修改httpd配置文件,使其配合smokeping使用

#A:为smokeping的web界面创建安全密码,"账户是admin,密码是12345678"
    htpasswd -c /opt/smokeping/htdocs/htpasswd admin

#B:修改httpd的配置文件,(在末尾添加下面的内容)
    vim /etc/httpd/conf/httpd.conf

Alias /cache "/opt/smokeping/cache/"
Alias /cropper "/opt/smokeping/htdocs/cropper/"
Alias /smokeping "/opt/smokeping/htdocs/smokeping.fcgi"
<Directory "/opt/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthName "Smokeping"
AuthType Basic
AuthUserFile /opt/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
</Directory>

第四:启动相关服务,并加入开机自起

/opt/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &
systemctl start httpd

echo "/opt/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local
chmod +x /etc/rc.d/rc.local
systemctl enable httpd

第五:配置监控项,添加主机

    vim /opt/smokeping/etc/config

*** Targets ***
#在Targets下添加监控主机项

+ Other
menu = 全国DNS网络监控
title = 全国DNS网络监控

++ dx
menu = 电信
title = 电信网络监控列表
host = /Other/dx/dx-jx  /Other/dx/dx-sh /Other/dx/dx-yn  /Other/dx/dx-hub /Other/dx/dx-sc
#注意:host= /Other/dx/dx-jx 的这里不能太长,太长可能导致smokeping不出图,如 host= /yw/sw/sw-4F-H18-kfw 就不会出图

+++ dx-jx
menu = 江西电信
title = 江西电信
alerts = someloss
host = 202.101.224.69

+++ dx-sh
menu = 上海电信
title = 上海电信
alerts = someloss
host = 202.96.209.133

+++ dx-yn
menu = 云南电信
title = 云南电信
alerts = someloss
host = 222.172.200.68

+++ dx-hub
menu = 湖北电信
title = 湖北古电信
alerts = someloss
host = 202.103.24.68

+++ dx-sc
menu = 四川电信
title = 四川古电信
alerts = someloss
host = 61.139.2.69

效果图如下:

下面附上一份较为完整的smokeping配置文件,以供参考

*** General ***

owner    = Peter Random
contact  = some@address.nowhere
mailhost = my.mail.host
sendmail = /usr/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 = /opt/smokeping/cache
imgurl   = cache
datadir  = /opt/smokeping/data
piddir  = /opt/smokeping/var
cgiurl   = http://223.84.153.89/smokeping.cgi
smokemail = /opt/smokeping/etc/smokemail.dist
tmail = /opt/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 = alertee@address.somewhere
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%,>20%,>20%,>20%
comment = 连续3次采样-丢包率超过20%

+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

charset = utf-8
+ charts

menu = 排行榜
title = 排行榜

++ stddev
sorter = StdDev(entries=>4)
title = 综合指数排行
menu = 综合指数排行
format = 综合指数 %f

++ max
sorter = Max(entries=>5)
title = 最大延迟排行
menu = 最大延迟排行
format = 最大延迟时间 %f 秒

++ loss
sorter = Loss(entries=>5)
title = 丢包率排行
menu = 丢包率排行
format = 丢包 %f

++ median
sorter = Median(entries=>5)
title = 中间数据包延迟排行
menu = 中间数据包延迟排行
format = 中间数据包延迟 %f 秒

+ 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

#+ hierarchies
#++ owner
#title = Host Owner
#++ location
#title = Location

*** Probes ***

+ FPing

binary = /usr/sbin/fping

*** Slaves ***
secrets=/opt/smokeping/etc/smokeping_secrets.dist

+tengxunyun
display_name=腾讯云slave
location=China
color=ff0000

*** 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.

#parents = owner:/Test/James location:/ owner:/JF/

+ Other
menu = 全国DNS网络监控
title = 全国DNS网络监控
#alerts = hostdown,hightloss

++ gg
menu = 公共DNS
title = 公共DNS网络监控列表
host = /Other/gg/gg-114 /Other/gg/gg-ali /Other/gg/gg-baidu /Other/gg/gg-dnspod /Other/gg/gg-cnnic /Other/gg/gg-one /Other/gg/gg-dnsp /Other/gg/gg-google /Other/gg/gg-open /Other/gg/gg-v2ex /Other/gg/gg-IBM-Q9 /Other/gg/gg-CloudFlare

+++ gg-114
menu = 114-DNS
title = 114-DNS
#slaves = tengxunyun
host = 114.114.114.114

+++ gg-ali
menu = 阿里-DNS
title = 阿里-DNS
host = 223.5.5.5

+++ gg-baidu
menu = 百度-DNS
title = 百度-DNS
host = 180.76.76.76

+++ gg-dnspod
menu = DNSPOD-DNS
title = DNSPOD-DNS
host = 119.29.29.29

+++ gg-cnnic
menu = CNNIC-DNS
title = CNNIC-DNS
host = 1.2.4.8

+++ gg-one
menu = one-DNS
title = one-DNS
host = 112.124.47.27

+++ gg-dnsp
menu = DNS派-DNS
title = DNS派-DNS
host = 218.30.118.6

+++ gg-google
menu = 谷歌-DNS
title = 谷歌-DNS
host = 8.8.8.8

+++ gg-open
menu = OPEN-DNS
title = OPEN-DNS
host = 208.67.222.222

+++ gg-v2ex
menu = V2EX-DNS
title = V2EX-DNS
host = 178.79.131.110

+++ gg-IBM-Q9
menu = IBM-Q9-DNS
title = IBM-Q9-DNS
host = 9.9.9.9

+++ gg-CloudFlare
menu = gg-CF-DNS
title = gg-CF-DNS
host = 1.1.1.1
声明:本文为原创,作者为 辣条①号,转载时请保留本声明及附带文章链接:https://boke.wsfnk.com/archives/346.html
谢谢你请我吃辣条谢谢你请我吃辣条

如果文章对你有帮助,欢迎点击上方按钮打赏作者

最后编辑于:2022/12/3作者: 辣条①号

现在在做什么? 接下来打算做什么? 你的目标什么? 期限还有多少? 进度如何? 不负遇见,不谈亏欠!

暂无评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

arrow grin ! ? cool roll eek evil razz mrgreen smile oops lol mad twisted wink idea cry shock neutral sad ???

文章目录