Linux下smokeping网络监控环境部署记录

时间:2022-04-23
本文章向大家介绍Linux下smokeping网络监控环境部署记录,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

smokeping是一款监控网络状态和稳定性的开源软件(它是rrdtool的作者开发的),通过它可以监控到公司IDC的网络状况,如延时,丢包率,是否BGP多线等; smokeping会向目标设备和系统发送各种类型的测试数据包,测量、记录,并通过rrdtool制图方式,图形化地展示网络的时延情况,进而能够清楚的判断出网络的即时通信情况;

通过smokeping来监控IDC机房网络质量情况,可以从监控图上的延时与丢包情况分辨出机房的网络是否稳定,是否为多线,是否为BGP机房以及到各城市的三个运行商网络各是什么情况。如果出现问题,可以有针对性的去处理;如果选择新机房的时候,还可以根据smokeping的监控结果来判断这个机房是否适合。 需要注意的是:smokeping监控的是网络稳定性,而cacti或zabbix监控的是带宽使用情况(即进出口流量)

下面就smokeping网络监控环境部署过程做一记录: 1)安装相关源 下载地址:https://pan.baidu.com/s/1pKBtm11 提取密码:erte [root@bastion-IDC ~]# rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

2)安装rrdtool与依赖库 [root@bastion-IDC ~]# 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

下载fping并编译安装 [root@bastion-IDC ~]# cd /usr/local/src/ [root@bastion-IDC src]# wget http://fping.org/dist/fping-3.10.tar.gz [root@bastion-IDC src]# tar -zvxf fping-3.10.tar.gz [root@bastion-IDC src]# cd fping-3.10 [root@bastion-IDC fping-3.10]# ./configure && make && make install

下载echoping并编译安装 [root@bastion-IDC ~]# cd /usr/local/src/ [root@bastion-IDC src]# wget http://down1.chinaunix.net/distfiles/echoping-5.2.0.tar.gz [root@bastion-IDC src]# tar -zvxf echoping-5.2.0.tar.gz [root@bastion-IDC src]# yum install -y popt libidn popt-devel libidn-devel          //安装echoping依赖的包 [root@bastion-IDC src]# cd echoping-5.2.0 [root@bastion-IDC echoping-5.2.0]# ./configure && make && make install

3)下载与安装smokeping [root@bastion-IDC ~]# cd /usr/local/src/ [root@bastion-IDC src]# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz [root@bastion-IDC src]# tar -zvxf smokeping-2.6.8.tar.gz [root@bastion-IDC src]# cd smokeping-2.6.8 [root@bastion-IDC smokeping-2.6.8]# ./configure --prefix=/usr/local/smokeping 出现下面报错信息: ** Aborting Configure ******************************

If you know where perl can find the missing modules, set the PERL5LIB environment variable accordingly.

FIRST though, make sure that 'perl' starts the perl binary you want to use for SmokePing.

Now you can install local copies of the missing modules by running

./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty

The RRDs perl module is part of RRDtool. Either use the rrdtool package provided by your OS or install rrdtool from source. If you install from source, the RRDs module is located PREFIX/lib/perl

出现问题是因为需要安装perl的模块,所以运行下面内容即可: [root@bastion-IDC smokeping-2.6.8]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty [root@bastion-IDC smokeping-2.6.8]# ./configure --prefix=/usr/local/smokeping [root@bastion-IDC smokeping-2.6.8]# /usr/bin/gmake install

4)配置smokeping 创建cache、data、var目录 [root@bastion-IDC yum.repos.d]# cd /usr/local/smokeping [root@bastion-IDC smokeping]# mkdir cache data var

创建日志 [root@bastion-IDC smokeping]# touch /var/log/smokeping.log

授权 [root@bastion-IDC smokeping]# chown apache:apache cache data var [root@bastion-IDC smokeping]# chown apache:apache /var/log/smokeping.log

修改配置文件 [root@bastion-IDC smokeping]# cd /usr/local/smokeping/htdocs/ [root@bastion-IDC htdocs]# mv smokeping.fcgi.dist smokeping.fcgi [root@bastion-IDC htdocs]# cd /usr/local/smokeping/etc [root@bastion-IDC etc]# mv config.dist config [root@bastion-IDC etc]# cp config config.bak [root@bastion-IDC etc]# vim config ........ cgiurl = http://smokeping.wangshibo.com/smokeping.cgi //默认是cgiurl = http://some.url/smokeping.cgi,把some.url修改为你的ip或者域名

*** Database ***

step = 60 //默认是300,这是检测的时间

配置完成之后修改密码文件权限 [root@bastion-IDC etc]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist

修改apache的配置 [root@bastion-IDC etc]# vim /etc/httpd/conf/httpd.conf                //添加下面内容 ....... Alias /cache "/usr/local/smokeping/cache/" Alias /cropper "/usr/local/smokeping/htdocs/cropper/" Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"  //smokeping访问地址就是http://smokeping.wangshibo.com/smokeping <Directory "/usr/local/smokeping"> AllowOverride None Options All AddHandler cgi-script .fcgi .cgi Order allow,deny Allow from all DirectoryIndex smokeping.fcgi </Directory>

图像浏览界面的中文支持 [root@bastion-IDC etc]# yum -y install wqy-zenhei-fonts.noarch

编辑smokeping的配置文件 [root@bastion-IDC etc]# vim /usr/local/smokeping/etc/config charset = utf-8              //第50行下面添加此行内容

编辑Graphs.pm [root@bastion-IDC etc]# vim /usr/local/smokeping/lib/Smokeping/Graphs.pm '--font TITLE:20:"WenQuanYi Zen Hei Mono"',                  //第147行下面插入边一行内容

接着进行测试数据的自定义(可以将smokeping部署在公司网络下,然后自定义监控各个IDC的网络情况,监控设置如下定义) [root@bastion-IDC etc]# 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

修改smokeping的config配置文件中fping路径 [root@bastion-IDC etc]# which fping /usr/local/sbin/fping [root@bastion-IDC etc]# vim config ...... binary = /usr/local/sbin/fping                 //默认配置的是/usr/sbin/fping

启动http [root@bastion-IDC etc]# /etc/init.d/httpd start            //最好将httpd.conf中的ServerName www.example.com:80这一行的注释打开

启动smokeping [root@bastion-IDC etc]# /usr/local/smokeping/bin/smokeping

设置smokeping开机启动 [root@bastion-IDC etc]# echo "/usr/local/smokeping/bin/smokeping" >> /etc/rc.local

设置smokeping环境变量 [root@bastion-IDC etc]# echo 'export PATH=/usr/local/smokeping/bin/:$PATH' >> /etc/profile

本地hosts绑定smokeping.wangshibo.com,然后访问上面部署的smokeping界面: http://smokeping.wangshibo.com/smokeping    (首次访问,采集数据需要一段时间,等一会就会有数据图形展示)

以上为实验环境,可根据自己实际的网络情况进行监控配置的修改。

如果按照上面操作后,直接在网上访问是十分的不安全,需要加入安全访问控制 修改apache的httpd.conf配置(将上面添加的apache配置直接如下覆盖或再添加如下红色字体内容) [root@bastion-IDC etc]# vim /etc/httpd/conf/httpd.conf .... 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 AllowOverride AuthConfig Order allow,deny Allow from all AuthName "Smokeping" AuthType Basic AuthUserFile /usr/local/smokeping/htdocs/htpasswd Require valid-user DirectoryIndex smokeping.fcgi </Directory>

设置访问的用户名和密码(比如admin/admin) [root@bastion-IDC etc]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin New password: Re-type new password: Adding password for user admin

重启apache [root@bastion-IDC etc]# /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]

再次访问smokeping界面