smokeping是一款監控網絡狀態和穩定性的開源軟件(它是rrdtool的做者開發的),經過它能夠監控到公司IDC的網絡情況,如延時,丟包率,是否BGP多線等;
smokeping會向目標設備和系統發送各類類型的測試數據包,測量、記錄,並經過rrdtool製圖方式,圖形化地展現網絡的時延狀況,進而可以清楚的判斷出網絡的即時通訊狀況;apache
經過smokeping來監控IDC機房網絡質量狀況,能夠從監控圖上的延時與丟包狀況分辨出機房的網絡是否穩定,是否爲多線,是否爲BGP機房以及到各城市的三個運行商網絡各是什麼狀況。若是出現問題,能夠有針對性的去處理;若是選擇新機房的時候,還能夠根據smokeping的監控結果來判斷這個機房是否適合。
須要注意的是:smokeping監控的是網絡穩定性,而cacti或zabbix監控的是帶寬使用狀況(即進出口流量)vim
下面就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_fastcgibash
下載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 curl
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 ******************************ide
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 runningui
./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界面