大家好,又见面了,我是你们的朋友全栈君。
一、smokeping介绍
我们在选择机房的时候,如何知道这个机房的网络情况,这个时候就要用到网络监控软件:smokeping
本文主要介绍如何使用smokeping来监控idc机房的网络质量情况,从监控图上的延时与丢包能分辨出你机房的网络是否稳定,是否为多线,是否为BGP机房,到各城市的3个运营商之间的网络,各是什么情况,如果出现问题,如何有针对性的解决。而且如果选择新机房的时候,你可以根据smokeping的监控结果来判断这个机房是否适合。
smokeping是rrdtool的作者Tobi Oetiker的作品,所以它在图形显示方面有很大优势,也是一个很 有特点的opensource工具:
1、多种探测方式,包括fping、echoping、dig、curl等; 2、易用可扩展的插件; 3、master/slave 的 工作方式,可以在多个节点收集同一个监测点的数据;
二、安装smokeping
1、软件环境:
代码语言:javascript复制[root@smokeping ~]# cat /etc/redhat-release
CentOS release 6.6 (Final)
[root@smokeping ~]# uname -r
2.6.32-504.el6.x86_64
2、下载软件
代码语言:javascript复制wget http://www.fping.org/dist/fping-3.10.tar.gz
wget https://fossies.org/linux/misc/old/echoping-6.0.2.tar.gz
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz
3、安装软件
1、安装依赖包:
yum install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-IO-Socket-SSL perl-Socket6 perl-Time-HiRes perl-ExtUtils-MakeMaker rrdtool rrdtool-perl curl 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 popt popt-devel libidn libidn-devel -y
2、解压、编译安装fping
代码语言:javascript复制tar xf fping-3.10.tar.gz
cd fping-3.10
./configure
make && make install
3、解压、编译安装echoping
代码语言:javascript复制tar xf echoping-6.0.2.tar.gz
cd echoping-6.0.2
./configure
make && make install
4、解压、编译安装smokeping
代码语言:javascript复制tar xf smokeping-2.6.9.tar.gz
cd smokeping-2.6.9
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
./configure --prefix=/usr/local/smokeping
/usr/bin/gmake install
5、配置 smokeping
代码语言:javascript复制cd /usr/local/smokeping/
mkdir cache data var
touch /var/log/smokeping.log
chown apache:apache cache data var
chown apache:apache /var/log/smokeping.log
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
cd /usr/local/smokeping/htdocs
mv smokeping.fcgi.dist smokeping.fcgi
cd /usr/local/smokeping/etc
mv config.dist config
6、更改配置文件
代码语言:javascript复制vim /usr/local/smokeping/etc/config
主要修改如下内容:
#cgiurl = http://some.url/smokeping.cgi
cgiurl = http://192.168.30.128/smokeping.cgi
*** Database ***
#step = 300
step = 60 #此处建议改为 60 , 一分钟采集一次数据
pings = 20
7、编辑apache配置文件
代码语言:javascript复制vim /etc/httpd/conf/httpd.conf
#在结尾添加如下代码:
#add smokeping configure file at 2017-04-10
Alias /cache "/usr/local/smokeping/cache/"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"
<Directory "/usr/local/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
Order allow,deny
Allow from all
DirectoryIndex smokeping.fcgi
</Directory>
8、图像浏览界面的中文支持 安装字体
代码语言:javascript复制yum -y install wqy-zenhei-fonts.noarch
编辑smokeping的配置文件
代码语言:javascript复制vim /usr/local/smokeping/etc/config
*** Presentation ***
charset = UTF-8 #添加这行,解决出图乱码问题
template = /usr/local/smokeping/etc/basepage.html.dist
编辑Graphs.pm
vi /usr/local/smokeping/lib/Smokeping/Graphs.pm #在第147行,下边插入这一行代码
代码语言:javascript复制'--font TITLE:20:"WenQuanYi Zen Hei Mono"',
如下图代码,标红部分
代码语言:javascript复制 if ($mode =~ /[anc]/){
my $val = 0;
for my $host (@hosts){
my ($graphret,$xs,$ys) = RRDs::graph
("dummy",
'--start', $tasks[0][1],
'--end', $tasks[0][2],
"DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:AVERAGE",
'--font TITLE:20:"WenQuanYi Zen Hei Mono"',
'PRINT:maxping:MAX:%le' );
my $ERROR = RRDs::error();
return "<div>RRDtool did not understand your input: $ERROR.</div>" if $ERROR;
$val = $graphret->[0] if $val < $graphret->[0];
}
$val = 1e-6 if $val =~ /nan/i;
$max = { $tasks[0][1] => $val * 1.5 };
}
9、##########测试数据可自定义##########
config 配置文件的最后边
代码语言:javascript复制vim /usr/local/smokeping/etc/config
Other
menu = 三大网络监控
title = 监控统计
dianxin
menu = 电信网络监控
title = 电信网络监控列表
host = /Other/dianxin/dianxin-bj /Other/dianxin/dianxin-hlj /Other/dianxin/dianxin-tj /Other/dianxin/dianxin-sc /Other/dianxin/dianxin-sh /Other/dianxin/dianxin-gz
dianxin-bj
menu = 北京电信
title = 北京电信
alerts = someloss
host = 202.96.199.133
dianxin-hlj
menu = 黑龙江电信
title = 黑龙江电信
alerts = someloss
host = 219.147.198.242
dianxin-tj
menu = 天津电信
title = 天津电信
alerts = someloss
host = 219.150.32.132
dianxin-sc
menu = 四川电信
title = 四川电信
alerts = someloss
host = 61.139.2.69
dianxin-sh
menu = 上海电信
title = 上海电信
alerts = someloss
host = 116.228.111.118
dianxin-gz
menu = 广东电信
title = 广东电信
alerts = someloss
host = 113.111.211.22
liantong
menu = 联通网络监控
title = 联通网络监控列表
host = /Other/liantong/liantong-bj /Other/liantong/liantong-hlj /Other/liantong/liantong-tj /Other/liantong/liantong-sc /Other/liantong/liantong-sh /Other/liantong/liantong-gz
liantong-bj
menu = 北京联通
title = 北京联通
alerts = someloss
host = 61.135.169.121
liantong-hlj
menu = 黑龙江联通
title = 黑龙江联通
alerts = someloss
host = 202.97.224.69
liantong-tj
menu = 天津联通
title = 天津联通
alerts = someloss
host = 202.99.96.68
liantong-sc
menu = 四川联通
title = 四川联通
alerts = someloss
host = 119.6.6.6
liantong-sh
menu = 上海联通
title = 上海联通
alerts = someloss
host = 210.22.84.3
liantong-gz
menu = 广东联通
title = 广东联通
alerts = someloss
host = 221.5.88.88
yidong
menu = 移动网络监控
title = 移动网络监控列表
host = /Other/yidong/yidong-bj /Other/yidong/yidong-hlj /Other/yidong/yidong-tj /Other/yidong/yidong-sc /Other/yidong/yidong-sh /Other/yidong/yidong-gz
yidong-bj
menu = 北京移动
title = 北京移动
alerts = someloss
host = 221.130.33.52
yidong-hlj
menu = 黑龙江移动
title = 黑龙江移动
alerts = someloss
host = 211.137.241.35
yidong-tj
menu = 天津移动
title = 天津移动
alerts = someloss
host = 211.137.160.5
yidong-sc
menu = 四川移动
title = 四川移动
alerts = someloss
host = 218.201.4.3
yidong-sh
menu = 上海移动
title = 上海移动
alerts = someloss
host = 117.131.19.23
yidong-gz
menu = 广东移动
title = 广东移动
alerts = someloss
host = 211.136.192.6
10、smokeping的默认配置文件110行的fping安装目录与此次安装目录不相符需修改!
代码语言:javascript复制vi /usr/local/smokeping/etc/config
#第110更改fping的目录为
binary = /usr/local/sbin/fping
11、启动apache服务和smokeping服务
代码语言:javascript复制#启动apache服务
[root@smokeping ~]# /etc/init.d/httpd start 正在启动 httpd:httpd: apr_sockaddr_info_get() failed for smokeping httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName [确定]
代码语言:javascript复制#重启apache服务
[root@smokeping ~]# /etc/init.d/httpd restart
停止 httpd:[确定]
正在启动 httpd:httpd: apr_sockaddr_info_get() failed for smokeping
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
#启动smokeping
/usr/local/smokeping/bin/smokeping
#检查
[root@smokeping ~]# ps -ef|grep smokeping
root 66206 1 0 23:47 ? 00:00:00 /usr/local/smokeping/bin/smokeping [FPing]
root 66476 1586 0 23:58 pts/0 00:00:00 grep smokeping
#杀smokeping进程号
[root@smokeping ~]# kill -9 66206
[root@smokeping ~]# kill -9 66206
-bash: kill: (66206) - 没有那个进程
#再启动smokeping
[root@smokeping ~]# /usr/local/smokeping/bin/smokeping
Note: logging to syslog as local0/info.
Daemonizing /usr/local/smokeping/bin/smokeping ...
12、设置环境变量
代码语言:javascript复制echo 'export PATH=/usr/local/smokeping/bin/:$PATH' >> /etc/profile
三、用数据说话(三大运营商网络监测图)
1、访问网站
代码语言:javascript复制http://192.168.30.128/smokeping
2、监控统计图
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/155795.html原文链接:https://javaforall.cn