解决方案

【smokeping】网络性能监控,机房网络评估

seo靠我 2023-09-25 15:02:19

更多内容请点击 我的博客 查看,欢迎来访。

介绍

选择机房时,需要知道机房的网络请况,就需要用到网络监控软件smokeping。

smokeping由Perl语言写成,底层依赖于rrdtool和fping。

主要SEO靠我是监视网络性能,包括常规的ping,用echoping监控www服务器性能,监控dns查询性能和监控ssh性能等。底层时以rrdtool做支持,使用画图来表示网络丢包和延迟。

从监控图上的延时与丢包能分SEO靠我辨出你机房的网络是否稳定,是否为多线,是否为BGP机房,到各城市的3个运营商之间的网络,各是什么情况,如果出现问题,如何有针对性的解决。而且如果选择新机房的时候,可以根据smokeping的监控结果来SEO靠我判断这个机房是否适合。

组成部分

smokeping整个系统正常运行需要:web服务器软件、smokeping主服务、探针,rrdtool。

web服务器软件

smokeping拥有直观高效且漂亮的webUISEO靠我,因此需要借助第三方web服务,默认使用的是apache服务,同时需要启用cgi模块。

smokeping主服务

smokeping主服务即smokeping工作进程,负责在后台(也可以前台)执行监测任务SEO靠我

探针

smokeping实际使用的监测工具即探针。默认探针是fping,常用探针例如:

fping 默认探针,使用icmp协议,可并发检测目标RTT(Round-Trip Time)数值echopingSEO靠我 echo服务检测,使用tcp/udp协议,默认端口号7tcpping tcp端口检测,使用tcp协议监测端口连通性和时延

更多关于探针的介绍可以参阅官方文档。

rrdtool

rrdtool(Round SEO靠我Robin Database Tool)即轮询调度数据库工具,使用C语言写成,是一种强大的绘图引擎,兼有时序数据库和绘图两种功能。rrdtool被许多监控平台所使用,如smokeping、cacti、SEO靠我open-falcon等。

安装配置smokeping

访问 https://oss.oetiker.ch/smokeping/doc/smokeping_install.en.html 可以看到安装步骤SEO靠我

[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core) [rSEO靠我oot@localhost ~]# uname -r 3.10.0-1062.4.1.el7.x86_64

smokeping需要依赖系统上的其他工具和服务,除了Unix操作Perl组件SEO靠我

环境依赖包安装

[root@localhost ~]# yum -y install wget vim curl [root@localhost ~]# yum -y install SEO靠我gcc gcc-c++ popt-devel

RRDtool 1.2.x or later

Smokeping使用RRDtool进行记录和绘图。如果linux提供了一个带有perl支持的rrdtool包,SEO靠我那么可以使用它。如果没有或安装新版

[root@localhost ~]# yum install rrdtool perl-rrdtool openssl-devel -y

FPing (可选)

smokSEO靠我eping 2.7.2 以上需要 fping4.0 以上,因此需要手动编译。可以访问 http://www.fping.org/ 下载

[root@localhost ~]# wget http://wSEO靠我ww.fping.org/dist/fping-4.2.tar.gz [root@localhost ~]# tar -xzf fping-4.2.tar.gz [roSEO靠我ot@localhost ~]# cd fping-4.2 [root@localhost fping-4.2]# ./configure [root@localhosSEO靠我t fping-4.2]# make && make install

EchoPing (可选)

需要它来运行echoping探测,做tcp ping,访问 https://github.com/bortSEO靠我zmeyer/echoping/ 进行查看。 http://bortzmeyer.github.io/echoping/ 官方说明,不在积极维护了。

[root@localhost ~]# wget hSEO靠我ttps://fossies.org/linux/misc/old/echoping-6.0.2.tar.gz [root@localhost ~]# tar xzf echopingSEO靠我-6.0.2.tar.gz [root@localhost ~]# cd echoping-6.0.2 [root@localhost echoping-6.0.2]#SEO靠我 yum install -y popt-devel [root@localhost echoping-6.0.2]# ./configure # 如果报错使用下面的配置 SEO靠我 [root@localhost echoping-6.0.2]# ./configure --with-ssl --without-libidn [root@localhost eSEO靠我choping-6.0.2]# make && make install

Webserver

http://httpd.apache.org/

重要的是,要有一个web服务器,它允许运行CGI,最好是FasSEO靠我tCGI脚本。如果使用的是Apache,强烈建议使用suexec系统作为特定用户运行CGI脚本。

有关更多信息,请查看 http://httpd.apache.org/mod_fcgid/mod/modSEO靠我_fcgid.html 和 http://httpd.apache.org/docs/2.2/mod/mod_suexec.html 。

注意smokeping是fcgi程序,因此apache 需要安装SEO靠我mod_fcgid, http的版本是 2.4.6

[root@localhost ~]# yum install httpd httpd-devel -y [root@localhosSEO靠我t ~]# yum install mod_fcgid -y [root@localhost ~]# systemctl enable httpd Created sySEO靠我mlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpSEO靠我d.service. [root@localhost ~]# systemctl start httpd# 查看Apache默认监听端口 [root@localhostSEO靠我 ~]# cat /etc/httpd/conf/httpd.conf | grep Listen | grep -v "#" Listen 80# 查看端口及服务 [SEO靠我root@localhost ~]# netstat -antp | grep httpd tcp6 0 0 :::80 :::* LISTEN 8572/httpd # 但是外部是不SEO靠我同的,需要开启CentOS的防火墙fireall-cmd [root@localhost ~]# firewall-cmd --permanent --zone=public --adSEO靠我d-port=80/tcp success # 操作完成后重载 [root@localhost ~]# firewall-cmd --reload SEO靠我 success

这时候访问该主机的IP http://xxx.xxx.xxx.xxx/ 即可以看到Apache的页面。

Perl 5.10.1 or later

[root@localhost SEO靠我~]# yum install perl-core -y

开始安装smokeping

安装的版本为 smokeping-2.7.3 ,为2019年11月16日最新

[root@localhost ~]# wSEO靠我get https://oss.oetiker.ch/smokeping/pub/smokeping-2.7.3.tar.gz [root@localhost ~]# tar xzf SEO靠我smokeping-2.7.3.tar.gz [root@localhost ~]# cd smokeping-2.7.3 [root@localhost smokepSEO靠我ing-2.7.3]# ./configure --prefix=/opt/smokeping** Ready to install Smokeping ***********************SEO靠我*******Settings:PERL5LIB = not setPERL = /usr/bin/perlThe Smokeping Makefiles use GNU make functionaSEO靠我lity.Continue installation with/usr/bin/gmake install

出现上面的错误,表示没有指定PERL5LIB,下面将加上

[root@localhost smoSEO靠我keping-2.7.3]# ./configure --prefix=/opt/smokeping PERL5LIB=/usr/lib64/perl5/** Ready to install SmoSEO靠我keping ******************************Settings:PERL5LIB = /usr/lib64/perl5/PERL = /usr/bin/perlThe SmSEO靠我okeping Makefiles use GNU make functionality.Continue installation with/usr/bin/gmake install[root@lSEO靠我ocalhost smokeping-2.7.3]# /usr/bin/gmake installMaking install in thirdparty gmake[1]: 进入目录SEO靠我“/root/smokeping-2.7.3/thirdparty”GEN touch Successfully installed FCGI-0.78 SuccessSEO靠我fully installed HTML-Tagset-3.20 Successfully installed HTML-Parser-3.72 SuccessfullSEO靠我y installed CGI-4.40 (upgraded from 3.59) Successfully installed CGI-Fast-2.13 (upgraded froSEO靠我m 1.09) Successfully installed Config-Grammar-1.12 Successfully installed Socket6-0.SEO靠我29 Successfully installed Net-SSLeay-1.85 Successfully installed Mozilla-CA-20180117SEO靠我 Successfully installed IO-Socket-SSL-2.060 Successfully installed Digest-HMAC-1.03 SEO靠我 Successfully installed Net-Telnet-3.04 Successfully installed Net-OpenSSH-0.78 SEO靠我 Successfully installed Net-SNMP-v6.0.1 Successfully installed Convert-ASN1-0.27 SSEO靠我uccessfully installed perl-ldap-0.65 Successfully installed IO-Socket-IP-0.39 SuccesSEO靠我sfully installed Net-DNS-1.19 Successfully installed IO-Tty-1.12 Successfully instalSEO靠我led URI-1.74 Successfully installed LWP-MediaTypes-6.02 Successfully installed EncodSEO靠我e-Locale-1.05 Successfully installed IO-HTML-1.001 Successfully installed HTTP-Date-SEO靠我6.02 Successfully installed HTTP-Message-6.18 Successfully installed File-Listing-6.SEO靠我04 Successfully installed HTTP-Negotiate-6.01 Successfully installed HTTP-Daemon-6.0SEO靠我1 Successfully installed Try-Tiny-0.30 Successfully installed Net-HTTP-6.18 SEO靠我Successfully installed HTTP-Cookies-6.04 Successfully installed WWW-RobotRules-6.02 SEO靠我Successfully installed libwww-perl-6.36 Successfully installed ExtUtils-MakeMaker-7.34 (upgrSEO靠我aded from 6.63_02) Successfully installed Net-IP-1.26 Successfully installed Data-HeSEO靠我xDump-0.02 Successfully installed Authen-Radius-0.29 Successfully installed Path-TinSEO靠我y-0.108 38 distributions installed # 安装成功

初始化smokeping

创建文件夹

需要建立三个文件夹,data用来存放 rrd 文件,SEO靠我var用来存放 smokeping 的 pid,/var/log用来存放 smokeping.log

[root@localhost ~]# cd /opt/smokeping# 从示例文件中,可以看到SEO靠我需要创建下面即可目录 [root@localhost smokeping]# cat etc/config.dist | grep /opt/smokeping imgSEO靠我cache = /opt/smokeping/cache datadir = /opt/smokeping/data piddir = /opt/smokeping/vSEO靠我ar smokemail = /opt/smokeping/etc/smokemail.dist tmail = /opt/smokeping/etc/tmail.diSEO靠我st template = /opt/smokeping/etc/basepage.html.dist secrets=/opt/smokeping/etc/smokeSEO靠我ping_secrets.dist# 创建需要的目录 [root@localhost smokeping]# mkdir data cache var [root@loSEO靠我calhost smokeping]# chown apache:apache cache data var [root@localhost smokeping]# chmod 777SEO靠我 data cache var# 创建日志文件 [root@localhost smokeping]# touch /var/log/smokeping.log [roSEO靠我ot@localhost smokeping]# chown apache:apache /var/log/smokeping.log

复制配置文件

[root@localhost smokeping]#SEO靠我 pwd /opt/smokeping # 查看有哪些文件 [root@localhost smokeping]# ls bin cacSEO靠我he data etc htdocs lib log share [root@localhost smokeping]# ls etc/ basepage.html.dSEO靠我ist config.dist examples smokemail.dist smokeping_secrets.dist tmail.dist [root@localhost smSEO靠我okeping]# ls htdocs/ css js smokeping.fcgi.dist# 创建smokeping的配置文件 [root@localhost smSEO靠我okeping]# cp etc/config.dist etc/config# 创建smokeping 页面启动文件 [root@localhost smokeping]# cp hSEO靠我tdocs/smokeping.fcgi.dist htdocs/smokeping.fcgi # 里面的内容如下,通过smokeping_cgi脚本配合config配置文件启动 SEO靠我 [root@localhost smokeping]# cat htdocs/smokeping.fcgi #!/bin/sh exec /opt/smokSEO靠我eping/bin/smokeping_cgi /opt/smokeping/etc/config# basepage.html 是webUI的模板页面,修改此文件可以对页面默认的颜色以及其他样式做定SEO靠我制 [root@localhost smokeping]# cp etc/basepage.html.dist etc/basepage.html# 用于设定主从验证 SEO靠我[root@localhost smokeping]# cp etc/smokeping_secrets.dist etc/smokeping_secrets

修改配置文件

[root@localhostSEO靠我 smokeping]# sed -i s#cgiurl = http://some.url/smokeping.cgi#cgiurl = http://192.168.99.101/smokepinSEO靠我g.cgi#g /opt/smokeping/etc/config # 图片url可以不做修改【不建议修改】 [root@localhost smokeping]# sSEO靠我ed -i s#imgurl = cache#imgurl = http://192.168.99.101/cache#g /opt/smokeping/etc/config # 默认SEO靠我检测时间300秒修改60秒 [root@localhost smokeping]# sed -i s#step = 300#step = 60#g /opt/smokeping/etcSEO靠我/config # 默认ping20次,修改为60秒ping60次 [root@localhost smokeping]# sed -i s#pings = 20#piSEO靠我ngs = 60#g /opt/smokeping/etc/config # 修改详情图detail显示高度,默认为200(第二处height) [root@localSEO靠我host smokeping]# sed -i s#height = 200#height = 600#g /opt/smokeping/etc/config # 修改概览图overvSEO靠我iew显示高度,默认为50(第一处height) [root@localhost smokeping]# sed -i s#height = 50#height = 200#g /opSEO靠我t/smokeping/etc/config # 修改默认模板页面 [root@localhost smokeping]# sed -i s#template = /oSEO靠我pt/smokeping/etc/basepage.html.dist#template = /opt/smokeping/etc/basepage.html#g /opt/smokeping/etcSEO靠我/config # 修改主从默认密码验证 [root@localhost smokeping]# sed -i s#secrets=/opt/smokeping/etcSEO靠我/smokeping_secrets.dist#secrets=/opt/smokeping/etc/smokeping_secrets#g /opt/smokeping/etc/config SEO靠我 # 修改fping默认位置,先找到fping位置:whereis fping | awk {print $2},进行一键替换 [root@localhost smokepinSEO靠我g]# sed -i s#binary = /usr/sbin/fping#binary = `whereis fping | awk {print $2}`#g /opt/smokeping/etcSEO靠我/config# 查看config中自己修改后的内容 [root@localhost smokeping]# egrep "cgiurl|imgurl|step|pings|heighSEO靠我t|template|secrets|binary" etc/config imgurl = cache # imgurl = http://192.168.99.10SEO靠我1/cache cgiurl = http://192.168.99.101/smokeping.cgi step = 60 pings = 60 SEO靠我 # consfn mrhb steps total template = /opt/smokeping/etc/basepage.html height =SEO靠我 200 height = 600 binary = /usr/local/sbin/fping secrets=/opt/smokeping/etc/SEO靠我smokeping_secrets

绘图支持显示中文

# 图片浏览器支持中文显示,防止中文乱码 # 中文支持修改第1处,安装字体 [root@localhost smokeSEO靠我ping]# yum -y install wqy-zenhei-fonts.noarch # 中文支持修改第2处,在presentation添加utf-8中文字符集,解决图乱码问题 SEO靠我 [root@localhost smokeping]# vim /opt/smokeping/etc/config # 省略 *** PresentatSEO靠我ion *** # 添加这一行 charset = utf-8 # 省略# 中文支持修改第3处,【实际测试可以不用加】 [root@loSEO靠我calhost smokeping]# vim /opt/smokeping/lib/Smokeping/Graphs.pm# 大概在150行左右if ($mode =~ /[anc]/){my $vSEO靠我al = 0;for my $host (@hosts){my ($graphret,$xs,$ys) = RRDs::graph("dummy",--start, $tasks[0][1],--enSEO靠我d, $tasks[0][2],# 添加下面这行--font TITLE:20:"WenQuanYi Zen Hei Mono","DEF:maxping=$cfg->{General}{datadiSEO靠我r}${host}.rrd:median:AVERAGE",PRINT:maxping:MAX:%le );my $ERROR = RRDs::error();return "<div>RRDtoolSEO靠我 did not understand your input: $ERROR.</div>" if $ERROR;$val = $graphret->[0] if $val < $graphret->SEO靠我[0];}$val = 1e-6 if $val =~ /nan/i;$max = { $tasks[0][1] => $val * 1.5 };}

权限验证

# 设置网页的登录用户名为smokepingSEO靠我,密码是自己输入的为smokeping [root@localhost smokeping]# htpasswd -c /opt/smokeping/htdocs/htpasswd sSEO靠我mokeping New password: smokeping Re-type new password: smokeping Adding passSEO靠我word for user smokeping# 可以看到用户名和加密后的密码记录到该文件中了 [root@localhost smokeping]# cat /opt/smokepiSEO靠我ng/htdocs/htpasswd smokeping:$apr1$cAduSlT.$NFgAIEKdenqs99YVNmq3e1# 修改密码权限为root只读 [rSEO靠我oot@localhost smokeping]# chmod 600 /opt/smokeping/etc/smokeping_secrets [root@localhost smoSEO靠我keping]# cat /opt/smokeping/etc/smokeping_secrets host1:mysercert host2:yoursercert SEO靠我 boomer:lkasdf93uhhfdfddf

手动启动smokeping

接下来进行手动启动

[root@localhost smokeping]# bin/smokeping --loSEO靠我gfile=/var/log/smokeping.log ERROR: /opt/smokeping/bin/../etc/config, line 112: ERROR: FPingSEO靠我 binary does not point to an executable # 启动失败,因为之前安装fping的路径是不一样的,需要进行修改,【如果前面已经修改过,则不用修改了】SEO靠我 [root@localhost smokeping]# whereis fping fping: /usr/local/sbin/fping [rooSEO靠我t@localhost smokeping]# vim etc/config # 找到112行修改 # binary = /usr/sbin/fping SEO靠我 binary = /usr/local/sbin/fping# 接下来启动 [root@localhost smokeping]# bin/smokeping --logfile=/SEO靠我var/log/smokeping.log Note: logging to syslog as local0/info. Daemonizing bin/smokepSEO靠我ing ...# 可以在日志里看到启动成功 [root@localhost smokeping]# cat /var/log/smokeping.log Sat NovSEO靠我 16 21:23:13 2019 - Smokeping version 2.007003 successfully launched. Sat Nov 16 21:23:13 20SEO靠我19 - Not entering multiprocess mode for just a single probe. Sat Nov 16 21:23:13 2019 - FPinSEO靠我g: probing 1 targets with step 60 s and offset 20 s.# 如果要停止smokeping进程 [root@localhost smokeSEO靠我ping]# ps -aux | grep smoke | grep -v grep root 34464 0.0 2.8 307688 28404 ? Ss 21:23 0:00 bSEO靠我in/smokeping [FPing] [root@localhost smokeping]# ps -aux | grep smoke | grep -v grep | awk {SEO靠我print $2} 34464 # 然后使用kill -9 进程号 即可

写入smokeping自启动文件

[root@localhost smokeping]# vim SEO靠我/etc/systemd/system/smokeping.service[Unit] Description=Smokeping Network performance monitoSEO靠我ring After=syslog.target network.target[Service] ExecStart=/opt/smokeping/bin/smokepSEO靠我ing --logfile=/var/log/smokeping.log ExecReload=/bin/kill -HUP $MAINPID StandardErroSEO靠我r=syslog Type=forking PIDFile=/opt/smokeping/var/smokeping.pid[Install] WantSEO靠我edBy=multi-user.target# 设置完之后重启daemon [root@localhost smokeping]# systemctl daemon-reload# 结SEO靠我束之前用命令启动的smokeping,然后用systemctl去启动 [root@localhost smokeping]# kill -9 `ps -aux | grep smokeSEO靠我 | grep -v grep | awk {print $2}` [root@localhost smokeping]# ps -aux | grep smoke | grep -vSEO靠我 grep | awk {print $2}# 启动smokeping并查看状态 [root@localhost smokeping]# systemctl start smokepiSEO靠我ng [root@localhost smokeping]# systemctl status smokeping ● smokeping.service - SmokSEO靠我eping Network performance monitoringLoaded: loaded (/etc/systemd/system/smokeping.service; disabled;SEO靠我 vendor preset: disabled)Active: active (running) since 六 2019-11-16 21:39:44 CST; 4s agoProcess: 34SEO靠我597 ExecStart=/opt/smokeping/bin/smokeping --logfile=/var/log/smokeping.log (code=exited, status=0/SSEO靠我UCCESS)Main PID: 34601 (/opt/smokeping/)CGroup: /system.slice/smokeping.service└─34601 /opt/smokepinSEO靠我g/bin/smokeping [FPing]# 同时查看 [root@localhost smokeping]# tail -f /var/log/smokeping.log 日志也会有相应的变化#SEO靠我 创建开机自启 [root@localhost smokeping]# systemctl enable smokeping Created symlink from SEO靠我/etc/systemd/system/multi-user.target.wants/smokeping.service to /etc/systemd/system/smokeping.serviSEO靠我ce.

修改Apache配置文件

[root@localhost smokeping]# vim /etc/httpd/conf/httpd.conf# 在下面一行之后添加以下内容 DocSEO靠我umentRoot "/var/www/html"Alias /cache "/opt/smokeping/cache/" # Alias /cropper "/opt/smokepiSEO靠我ng/htdocs/cropper/" Alias /css "/opt/smokeping/htdocs/css/" Alias /js "/opt/smokepinSEO靠我g/htdocs/js/" Alias /smokeping "/opt/smokeping/htdocs/smokeping.fcgi"<Directory "/opt/smokepSEO靠我ing">AllowOverride NoneOptions AllAddHandler cgi-script .fcgi .cgiOrder allow,denyAllow from all# 密码SEO靠我认证AuthName "Smokeping"AuthType BasicAuthUserFile /opt/smokeping/htdocs/htpasswdRequire valid-userDirSEO靠我ectoryIndex smokeping.fcgi </Directory># 设置完成后重启Apache服务 [root@localhost smokeping]#SEO靠我 systemctl restart httpd

浏览器访问 http://192.168.99.101/smokeping 就需要输入刚才设置的帐密,也就是smokeping:smokeping

配置监SEO靠我控目标

修改配置文件,在后面注释掉Test段落,添加自己的节点

[root@localhost smokeping]# vim /opt/smokeping/etc/config# 省略 SEO靠我*** Targets ***probe = FPingmenu = Top title = Network Latency Grapher remark = WelcSEO靠我ome to the SmokePing website of xxx Company. \Here you will learn all about the latency of our netwoSEO靠我rk.#+ Test #menu= Targets ##parents = owner:/Test/James location:/#++ James#menu = JSEO靠我ames #title =James #alerts = someloss #slaves = boomer slave2 #host SEO靠我= james.address#++ MultiHost#menu = Multihost #title = James and James as seen from Boomer SEO靠我 #host = /Test/James /Test/James~boomer# 添加监测源的IP库,加入到config中,修改后重启smokeping才会生效 # 添加监SEO靠我控节点示例:注意+是第一层,++是第二层,+++ 是第三层# 注释掉上面的,添加下面的监控节点 + NetMonitor menu = 三大网络监控 tSEO靠我itle = 监控统计++ dianxin menu = 电信网络监控 title = 电信网络监控列表 host = /NetMonitor/dianSEO靠我xin/dianxin-bj /NetMonitor/dianxin/dianxin-sc+++ dianxin-bj menu = 北京电信 title = 北京电信SEO靠我 alerts = someloss host = 202.96.199.133+++ dianxin-sc menu = 四川电信 tSEO靠我itle = 四川电信 alerts = someloss host = 61.139.2.69++ liantong menu = 联通网络监控 SEO靠我 title = 联通网络监控列表 host = /NetMonitor/liantong/liantong-bj /NetMonitor/liantong/liantongSEO靠我-gz+++ liantong-bj menu = 北京联通 title = 北京联通 alerts = someloss host =SEO靠我 61.135.169.121+++ liantong-gz menu = 广东联通 title = 广东联通 alerts = someloss SEO靠我 host = 221.5.88.88++ yidong menu = 移动网络监控 title = 移动网络监控列表 host = /NetSEO靠我Monitor/yidong/yidong-sc /NetMonitor/yidong/yidong-gz+++ yidong-sc menu = 四川移动 titleSEO靠我 = 四川移动 alerts = someloss host = 218.201.4.3+++ yidong-gz menu = 广东移动 SEO靠我 title = 广东移动 alerts = someloss host = 211.136.192.6

注意,在host中需要指定每一组节点信息例如host = /第SEO靠我一层/第二层/第三层,否则,浏览器访问指定该名称时会报错。添加监控节点后需要重启smokeping服务

[root@localhost smokeping]# systemctl restart smoSEO靠我keping

但是报错啊,不过日志中这个WARNING不影响smokeping的正常运行。

[root@localhost ~]# tail -f /var/log/smokeping.log Sat NSEO靠我ov 16 22:50:36 2019 - FPing: WARNING: smokeping took 60.1801409721375 seconds to complete 1 round ofSEO靠我 polling. It should complete polling in 60 seconds. You may have unresponsive devices in your setup.SEO靠我

关闭Selinux

主要是页面上访问会提示创建目录失败,也就是无权限

Software error: ERROR: creating /opt/smokeping/cache/NetMonSEO靠我itor: No such file or directory

解决办法是关闭Selinux

# 临时关闭 [root@localhost smokeping]# getenforce SEO靠我 Enforcing [root@localhost smokeping]# setenforce 0 [root@localhost smokeping]SEO靠我# getenforce Permissive # 如果需要永久关闭 vim /etc/sysconfig/selinux ,SELINUX=enforcing 改为 SEO靠我SELINUX=disabled 然后重启

蜜汁问题,smokeping终于正常创建目录了,绘图也正常了

绿色线绘出的是中间值(median)的位置,一个周期内探测返回的其它值都在中间值附近被以灰度的形式SEO靠我显示,灰度的范围越小说明此周期内抖动较小,灰度的颜色也有深浅,颜色越深,说明RTT值在此范围相对集中,灰色区域如烟雾般笼罩在中间值附近,很契合smokeping的名称。

smokeping配置文件解释

SEO靠我础配置信息

可以更改所有者(owner)、联系方式(contact)、邮件服务器(mailhost)、主站cgi地址(cgiurl,此选项对主从架构很重要)、syslog消息类型(syslogfacilSEO靠我ity)。同时,通过@include字段引用了同目录下的pathnames。

*** General ***owner = Peter Random contact = some@addSEO靠我ress.nowhere mailhost = my.mail.host sendmail = /usr/sbin/sendmail # NOTE: dSEO靠我o not put the Image Cache below cgi-bin # since all files under cgi-bin will be executed ...SEO靠我 this is not # good for images. imgcache = /opt/smokeping/cache imgurl = cacSEO靠我he # imgurl = http://192.168.99.101/cache datadir = /opt/smokeping/data piddSEO靠我ir = /opt/smokeping/var cgiurl = http://192.168.99.101/smokeping.cgi smokemail = /opSEO靠我t/smokeping/etc/smokemail.dist tmail = /opt/smokeping/etc/tmail.dist # specify this SEO靠我to get syslog logging syslogfacility = local0 # each probe is now run in its own proSEO靠我cess # disable this to revert to the old behaviour # concurrentprobes = no

报警规则

缺省条件下,SEO靠我采用sendmail邮件报警的方式,to 即接收方,from 即发送方。someloss是预定义的一个默认检测器,检测器不仅仅是一个阈值,它可以定义一组RTT从旧到新的变化过程,pattern 的值以SEO靠我一个运算符开始,按照从旧到新的状态变化,示例中,>0% 表示有丢包,*12* 表示在该组中最大忽略匹配12个数值,因此这段定义的意义是:匹配一组数据是否满足丢包次数大于等于3次。

*** Alerts SEO靠我*** to = alertee@address.somewhere from = smokealert@company.xy+someloss typSEO靠我e = loss # in percent pattern = >0%,*12*,>0%,*12*,>0% comment = loss 3 timesSEO靠我 in a row

数据库

描述rrd数据库的属性。

更改数据库配置文件无法对现有的rrd起作用,更改数据库配置文件后,需要清理现有的rrd缓存以使程序正常工作,默认rrd目录为:/opt/smokepinSEO靠我g/data/,也就是自己配置的data目录。step 表示基本操作间隔,即smokeping探测目标主机的间隔,默认300秒,pings表示在一次探测动作中,发出探测包的数量,step 和 pingSEO靠我s 的值均可以被后续的探针设置所覆盖。此配置也包含数据库归档合并的规则,共4列:合并方法、允许未知数值比例、步进,存储总行数。每一行表示一条RRA(循环归档)存储规则,预定义了多条AVERAGE、MISEO靠我N,MAX规则。以AVERAGE为例,第一条AVERAGE,步进1,行数1008,按照缺省step=300的条件下,表示5分钟一条,最大1008条,共存储3.5天数据,这是以此精度绘图的最大时间范围,SEO靠我如果超出范围,将会继续匹配合适的RRA,比如第二条AVERAGE,存储的时间范围是180天,但是精度是1小时。

*** Database ***step = 60 pings = 60#SEO靠我 consfn mrhb steps totalAVERAGE 0.5 1 1008 AVERAGE 0.5 12 4360MIN 0.5 12 4360MAX 0.5 12 4360SEO靠我 AVERAGE 0.5 144 760MAX 0.5 144 760MIN 0.5 144 760

定义显示规则

template 即webUI使用的网页模板,默认指向/opt/smokSEO靠我eping/etc/basepage.html,模板中包含各种表单关键字。charset 即文档编码,默认使用UTF-8

*** Presentation ***charset = utf-8 SEO靠我 template = /opt/smokeping/etc/basepage.html htmltitle = yes graphborders = no+ cSEO靠我hartsmenu = Charts title = The most interesting destinations++ stddev sorter = StdDeSEO靠我v(entries=>4) title = Top Standard Deviation menu = Std Deviation format = SSEO靠我tandard Deviation %f++ max sorter = Max(entries=>5) title = Top Max Roundtrip Time SEO靠我 menu = by Max format = Max Roundtrip Time %f seconds++ loss sorter = Loss(entSEO靠我ries=>5) title = Top Packet Loss menu = Loss format = Packets Lost %f++ mediSEO靠我an sorter = Median(entries=>5) title = Top Median Roundtrip Time menu = by MSEO靠我edian format = Median RTT %f seconds# smokeping支持报表功能,允许以特定的标准对图形目标排序显示。menu 表示菜单名称,title表示显SEO靠我示标题。 # 在子配置项中,可以看到sorter选项,通过此选项可以制定排序器,针对RTT的统计, # 内置了:标准差 StdDev(arg1=>val1,arg2=>SEO靠我val2),最大 Max(arg1=>val1,arg2=>val2),丢包率 Loss(arg1=>val1,arg2=>val2)等排序方法。 # format选项表示图例输出格式SEO靠我,此格式参考fprint字符串格式。+ overview width = 600 height = 200 range = 10h# overview 部分,定义了概述SEO靠我图的外观,宽 width,高 height, # 时间跨度 range,range的格式可以是s(seconds), m(minutes), h(hours), d(days), w(SEO靠我weeks), y(years)。+ detailwidth = 600 height = 600 unison_tolerance = 2# detail部分定义了详SEO靠我细图的外观,宽 width,高 height,unison_tolerance 规定了统一缩放的因子, # 此值必须参照每轮探测RTT结果的max中间值即median max,实际是为SEO靠我了保证图形缩放时的可读性,默认值为2, # 表示任何最大值小于中间值“max”一半或两倍以上的图都将从统一缩放中删除。"Last 3 Hours" 3h "Last 3SEO靠我0 Hours" 30h "Last 10 Days" 10d "Last 400 Days" 400d# detail 也包含可定义图形时间尺度的部分,包含两列:图形SEO靠我时间尺度的描述和时间跨度值,此值的格式与overview部分的range格式一致。#+ hierarchies #++ owner #title = Host OwneSEO靠我r #++ location #title = Location

配置探针模块

smokeping支持很多探针模块,最常用的就是内联的fping。

*** Probes **SEO靠我*+ FPing# binary = /usr/sbin/fping binary = /usr/local/sbin/fping

主从配置

在使用主从结构时,需要一个验证文件,即secrSEO靠我ets指定的值,默认为 /opt/smokeping/etc/smokeping_secrets,对于每一个从节点,还需要指定显示名称 display_name,显示颜色 color(此颜色指的是概述SEO靠我图上的线色,非细节图),颜色代码采用RRGGBB形式。

*** Slaves *** secrets=/opt/smokeping/etc/smokeping_secrets SEO靠我 +boomer display_name=boomer color=0000ff+slave2 display_name=another SEO靠我 color=00ff00

定义监控目标各项参数

Target是搭建snokeping主要配置的部分。menu定义了条目的菜单名称,title定义了条目的标题名称,host 定义了目标主机名,aleSEO靠我rts定义了使用的报警器,probe定义了使用的探针,slaves定义了需要使用的从服务器列表。同样,子条目的参数会继承父条目,也可以进行覆盖。

*** Targets ***probe = FPingSEO靠我menu = Top title = Network Latency Grapher remark = Welcome to the SmokePing websiteSEO靠我 of xxx Company. \Here you will learn all about the latency of our network.#+ Test #menu= TaSEO靠我rgets ##parents = owner:/Test/James location:/#++ James#menu = James #title =James SEO靠我 #alerts = someloss #slaves = boomer slave2 #host = james.address#++ MultiHostSEO靠我#menu = Multihost #title = James and James as seen from Boomer #host = /Test/James /SEO靠我Test/James~boomer+ NetMonitor menu = 三大网络监控 title = 监控统计++ dianxin menu = 电信SEO靠我网络监控 title = 电信网络监控列表 host = /NetMonitor/dianxin/dianxin-bj /NetMonitor/dianxin/dianSEO靠我xin-sc+++ dianxin-bj menu = 北京电信 title = 北京电信 alerts = someloss hostSEO靠我 = 202.96.199.133+++ dianxin-sc menu = 四川电信 title = 四川电信 alerts = someloss SEO靠我 host = 61.139.2.69++ liantong menu = 联通网络监控 title = 联通网络监控列表 host = /SEO靠我NetMonitor/liantong/liantong-bj /NetMonitor/liantong/liantong-gz+++ liantong-bj menu = 北京联通 SEO靠我 title = 北京联通 alerts = someloss host = 61.135.169.121+++ liantong-gz SEO靠我menu = 广东联通 title = 广东联通 alerts = someloss host = 221.5.88.88++ yidong SEO靠我 menu = 移动网络监控 title = 移动网络监控列表 host = /NetMonitor/yidong/yidong-sc /NetMonitor/yiSEO靠我dong/yidong-gz+++ yidong-sc menu = 四川移动 title = 四川移动 alerts = someloss SEO靠我 host = 218.201.4.3+++ yidong-gz menu = 广东移动 title = 广东移动 alerts = somelosSEO靠我s host = 211.136.192.6

独立监控目标文件

可以将监控的节点独立出来,然后使用@include xxx指定这个文件即可。也就是可以不用在config配置文件中加上监控ISEO靠我P的配置,直接独立出来即可。

在config同一目录下创建一个文件

[root@localhost smokeping]# vim etc/net_test.list# 添加 + NetMSEO靠我onitor_test menu = 三大网络监控_include title = 监控统计++ dianxin menu = 电信网络监控 SEO靠我 title = 电信网络监控列表 host = /NetMonitor_test/dianxin/dianxin-bj /NetMonitor_test/dianxin/dianSEO靠我xin-sc+++ dianxin-bj menu = 北京电信 title = 北京电信 alerts = someloss hostSEO靠我 = 202.96.199.133+++ dianxin-sc menu = 四川电信 title = 四川电信 alerts = someloss SEO靠我 host = 61.139.2.69++ liantong menu = 联通网络监控 title = 联通网络监控列表 host = /SEO靠我NetMonitor_test/liantong/liantong-bj /NetMonitor_test/liantong/liantong-gz+++ liantong-bj meSEO靠我nu = 北京联通 title = 北京联通 alerts = someloss host = 61.135.169.121+++ liantong-gSEO靠我z menu = 广东联通 title = 广东联通 alerts = someloss host = 221.5.88.88++ yiSEO靠我dong menu = 移动网络监控 title = 移动网络监控列表 host = /NetMonitor_test/yidong/yidong-scSEO靠我 /NetMonitor_test/yidong/yidong-gz+++ yidong-sc menu = 四川移动 title = 四川移动 aleSEO靠我rts = someloss host = 218.201.4.3+++ yidong-gz menu = 广东移动 title = 广东移动 SEO靠我 alerts = someloss host = 211.136.192.6

修改smokeping的配置文件,在最后引入这个配置

[root@localhost smokepinSEO靠我g]# vim etc/config # 最后添加 @include net_test.list[root@localhost smokeping]# systemctSEO靠我l restart smokeping

现在就增加了另一项。

“SEO靠我”的新闻页面文章、图片、音频、视频等稿件均为自媒体人、第三方机构发布或转载。如稿件涉及版权等问题,请与 我们联系删除或处理,客服邮箱:html5sh@163.com,稿件内容仅为传递更多信息之目的,不代表本网观点,亦不代表本网站赞同 其观点或证实其内容的真实性。

网站备案号:浙ICP备17034767号-2