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界面


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM