smokeping網絡監控

1、smokeping介紹

  咱們在選擇機房的時候,如何知道這個機房的網絡狀況,這個時候就要用到網絡監控軟件:smokeping  html

  本文主要介紹如何使用smokeping來監控idc機房的網絡質量狀況,從監控圖上的延時與丟包能分辨出你機房的網絡是否穩定,是否爲多線,是否爲BGP機房,到各城市的3個運營商之間的網絡,各是什麼狀況,若是出現問題,如何有針對性的解決。並且若是選擇新機房的時候,你能夠根據smokeping的監控結果來判斷這個機房是否適合。python

smokepingrrdtool的做者Tobi Oetiker的做品,因此它在圖形顯示方面有很大優點,也是一個很 有特色的opensource工具:linux

一、多種探測方式,包括fping、echoping、dig、curl等;
二、易用可擴展的插件;
三、master/slave
 的 工做方式,能夠在多個節點收集同一個監測點的數據;apache

 

2、安裝smokeping

一、軟件環境:vim

[root@smokeping ~]# cat /etc/redhat-release 
CentOS release 6.6 (Final)
[root@smokeping ~]# uname -r
2.6.32-504.el6.x86_64

二、下載軟件bash

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

三、安裝軟件網絡

一、安裝依賴包:dom

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 -ycurl

二、解壓、編譯安裝fpingide

tar xf fping-3.10.tar.gz
cd fping-3.10
./configure
make && make install

三、解壓、編譯安裝echoping

tar xf echoping-6.0.2.tar.gz
cd echoping-6.0.2
./configure
make && make install

四、解壓、編譯安裝smokeping

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

五、配置 smokeping 

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

六、更改配置文件

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

七、編輯apache配置文件

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>

八、圖像瀏覽界面的中文支持
安裝字體

yum -y install wqy-zenhei-fonts.noarch

編輯smokeping的配置文件

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行,下邊插入這一行代碼

'--font TITLE:20:"WenQuanYi Zen Hei Mono"',

以下圖代碼,標紅部分

    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 };
    }

九、##########測試數據可自定義##########

config 配置文件的最後邊

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的默認配置文件110行的fping安裝目錄與這次安裝目錄不相符需修改!

vi /usr/local/smokeping/etc/config

#第110更改fping的目錄爲
binary = /usr/local/sbin/fping

十一、啓動apache服務和smokeping服務

#啓動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
  [肯定]

#重啓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 ...

十二、設置環境變量

echo 'export PATH=/usr/local/smokeping/bin/:$PATH' >> /etc/profile

 

3、用數聽說話(三大運營商網絡監測圖)

一、訪問網站

http://192.168.30.128/smokeping 

二、監控統計圖

相關文章
相關標籤/搜索