歡迎您光臨本站 註冊首頁

配置 SmokePing --轉

←手機掃碼閱讀     火星人 @ 2014-03-03 , reply:0

配置 SmokePing --轉

配置 SmokePing --轉


RHEL-5.3
===================================================================================
【實際需求】

做為網站公司一般都會要求我們 IT 部提供全國各地 IDC 網路速度如何?質量?穩定性等等?
一般 ISP 或者代理公司會給出測試伺服器供我們測試該 IDC 的網路情況如何?
比如 windows 伺服器中有雷傲測試工具等等、就是通過在高峰時間段 ping 各地區的信息港或者骨幹網路的 IP 地址;最後分析統計該時間段內的 ping 值數據的平均值和丟包率等;
===================================================================================SmokePing
【Smokeping 簡介】
是 rrdtool 的作者 Tobi Oetiker 的作品,所以它在圖形顯示方面有很大優勢,也是一個很有特點的 opensource 工具:
多種探測方式,包括 fping、echoping、dig、curl 等;
易用可擴展的插件;
master/slave 的工作方式,可以在多個節點收集同一個監測點的數據;
很有特色的 alert 設置,不只是簡單的設置一個閥值。
===================================================================================
【系統配置 RHEL-5.3】

關閉 防火牆
# service iptables stop
Flushing firewall rules:                                 [ OK ]
Setting chains to policy ACCEPT: filter                   [ OK ]
Unloading iptables modules:                                  [ OK ]

關閉 selinux
# system-config-selinux

# setenforce 0

# vi /etc/sysconfig/selinux
將 SELINUX=enforcing
改成 SELINUX=disabled
重啟後生效
===================================================================================
【安裝相關軟體】
smokeping 是一個用 perl 寫的程序,所以不需要安裝。但是他需要使用一些工具以及 perl 的 module,還有 rrdtool、fping、echoping 等,這些都需要預先安裝好。smokeping 啟動的時候,也會自己去檢查需要用到的程序是否能找到。

我已經配置好了 yum :

# yum install gcc
# yum install freetype-devel
# yum install zlib-devel
# yum install libpng-devel
# yum install libart_lgpl-devel
# yum install httpd-devel
# yum install apr-util-devel
# yum install apr-devel
# yum install perl*

# yum install gcc freetype-devel zlib-devel libpng-devel libart_lgpl-devel httpd-devel apr-util-devel apr-devel freetype libart_lgpl libpng zlib perl*

除了以上的 rpm 包,還需手動安裝以下的包。
【rrdtool】【cgilib】【fping-2.4b2_to】【echoping】【CGI-SpeedyCGI-2.22】【smokeping】
===================================================================================
【rrdtool】

rrdtool 依賴以下程序
# yum install freetype
# yum install libart_lgpl
# yum install libpng
# yum install zlib
# yum install freetype libart_lgpl libpng zlib

# wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.6.tar.gz
# tar zxvf rrdtool-1.3.6.tar.gz
# cd rrdtool-1.3.6
# ./configure --disable-tcl
----------------------------------------------------------------
Config is DONE!

With MMAP IO: yes
Build rrd_getopt: no
Static programs: no
Perl Modules: perl_piped perl_shared
Perl Binary: /usr/bin/perl
Perl Version: 5.8.8
Perl Options: PREFIX=$(DESTDIR)/usr/local/rrdtool-1.3.6 LIB=$(DESTDIR)/usr/local/rrdtool-1.3.6/lib/perl/5.8.8
Ruby Modules:
Ruby Binary: no
Ruby Options: sitedir=$(DESTDIR)/usr/local/rrdtool-1.3.6/lib/ruby
Build Tcl Bindings: no
Build Python Bindings: yes
Build rrdcgi: yes
Build librrd MT: yes
Link with libintl: yes

Libraries: -lxml2 -lcairo -lcairo -lcairo -lm  -lcairo -lpng12   -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0  

Type 'make' to compile the software and use 'make install' to
install everything to: /usr/local/rrdtool-1.3.6.

... that wishlist is NO JOKE. If you find RRDtool useful
make me happy. Go to http://tobi.oetiker.ch/wish and
place an order.

-- Tobi Oetiker <tobi@oetiker.ch>
----------------------------------------------------------------

# make
# make install
# whereis rrdtool
   rrdtool: /usr/local/rrdtool

完成後執行cd ..退回安裝包的目錄
------------------------------------------------------------------------------------------------------------------------------------
【cgilib】
# wget http://down1.chinaunix.net/distfiles/cgilib-0.5.tar.gz
# tar zxvf cgilib-0.5.tar.gz
# cd cgilib-0.5
# make
# cp libcgi.a /usr/local/lib
# cp cgi.h /usr/include
------------------------------------------------------------------------------------------------------------------------------------
【fping-2.4b2_to】
# wget http://fping.sourceforge.net/download/fping.tar.gz
# tar zxvf fping.tar.gz
# cd fping-2.4b2_to
# ./configure
# make
# make check
# make install
# whereis fping
fping: /usr/local/sbin/fping
------------------------------------------------------------------------------------------------------------------------------------
【echoping】
# wget http://jaist.dl.sourceforge.net/ ... hoping-6.0.0.tar.gz
# tar zxvf echoping-6.0.0.tar.gz
# cd echoping-6.0.0
# ./configure
# make
# make test
遇到測試不成功等信息就 ctrl+c 回到命令行;
# make install
# whereis echoping
echoping: /usr/local/bin/echoping /usr/local/lib/echoping
------------------------------------------------------------------------------------------------------------------------------------
【CGI-SpeedyCGI-2.22】
# wget http://daemoninc.com/SpeedyCGI/CGI-SpeedyCGI-2.22.tar.gz
# tar zxvf CGI-SpeedyCGI-2.22.tar.gz
# cd CGI-SpeedyCGI-2.22
# perl Makefile.PL

Optional mod_speedycgi support.

Mod_speedycgi increases performance under Apache by avoiding the fork/exec
overhead associated with each request under normal SpeedyCGI. However, it
requires a working copy of "apxs" in your path, Apache with mod_so
support, and additional Apache configuration.

Compile mod_speedycgi (default no)? n
遇到問題選擇默認選項(no)

# ls /etc/httpd/modules/
libphp5.so          mod_cgid.so        mod_include.so        mod_proxy.so
……
mod_cern_meta.so    mod_imap.so        mod_proxy_http.so

這個目錄下沒有 mod_speedycgi.so,現在需要去下載安裝 mod_speedycgi.so

搜到了一個源
# wget ftp://195.220.108.108/linux/epel ... 2.22-4.el5.i386.rpm

# rpm -ivh mod_speedycgi-2.22-4.el5.i386.rpm
warning: mod_speedycgi-2.22-4.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
error: Failed dependencies:
perl-CGI-SpeedyCGI = 2.22-4.el5 is needed by mod_speedycgi-2.22-4.el5.i386

# wget ftp://fr.rpmfind.net/linux/EPEL/ ... 2.22-4.el5.i386.rpm
# rpm -ivh --force perl-CGI-SpeedyCGI-2.22-4.el5.i386.rpm
# rpm -ivh mod_speedycgi-2.22-4.el5.i386.rpm
# perl Makefile.PL

# make
# make test
# make install

完成後執行 cd ..退回安裝包的目錄
===================================================================================
三、配置【smokeping】

① 下載、解壓文件
# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.3.6.tar.gz
# tar zxvf smokeping-2.3.6.tar.gz
# mv smokeping-2.3.6 /smokeping
# cd /smokeping/smokeping-2.3.6
------------------------------------------------------------------------------------------------------------------------------------
② 生成文件

bin/ 下的 smokeping.dist
# cp smokeping.dist smokeping

etc/ 下的 basepage.html.dist,config.dist,smokemail.dist
# cp basepage.html.dist basepage.html
# cp config.dist config
# cp smokemail.dist smokemail
# chmod 600 smokeping_secrets.dist

htdocs/smokeping.cgi.dist
# cp smokeping.cgi.dist smokeping.cgi

/etc/ 下的 config-echoping.dist 可以先不去掉.dist;
------------------------------------------------------------------------------------------------------------------------------------
③ 按下面的步驟改參數:

配置 bin/smokeping
# vi /smokeping/smokeping-2.3.6/bin/smokeping
主程序,運行在後台。
在這個文件裡面我們需要修改前面兩個 lib 和後面 config 文件的 path。
兩個 lib 分別是 smokeping 的 lib 和 rrdtool 的 lib 。

我的 smokeping 安裝在 /usr/local/ 目錄中,所以我的設置是:

將以下幾行替換為已經安裝的相關軟體的路徑(將橙黃色改為淺黃色):

#!/usr/sepp/bin/perl-5.8.4 -w
#!/usr/bin/perl -w

use lib qw(/usr/pack/rrdtool-1.2.23-mo/lib/perl);
use lib qw(/usr/local/rrdtool-1.3.6/lib/perl);

use lib qw(lib);
use lib qw(/smokeping/smokeping-2.3.6/lib);

use Smokeping 2.003006;

Smokeping::main("etc/config.dist");
Smokeping::main("/smokeping/smokeping-2.3.6/etc/config");


配置 htdocs/smokeping.cgi
# vi /smokeping/smokeping-2.3.6/htdocs/smokeping.cgi
這個文件顯示頁面、圖像和作為 slave 傳輸數據的介面,設置方法與"bin/smokeping"類似。
但是第一行的 speedy 的路徑可能需要修改,否則瀏覽器中只會看到一個白色的頁面。
將以下幾行替換為已經安裝的相關軟體的路徑(將橙黃色改為淺黃色):
#!/usr/sepp/bin/speedy -w
# -*-perl-*-
#!/usr/bin/speedy -w
# -*-perl-*-

# use lib qw(/usr/pack/rrdtool-1.0.33-to/lib/perl);
use lib qw(/usr/local/rrdtool-1.3.6/lib/perl/);

# use lib qw(/home/oetiker/data/projects/AADJ-smokeping/dist/lib);
use lib qw(/smokeping/smokeping-2.3.6/lib);

use Smokeping 2.003006;

Smokeping::cgi("/home/oetiker/data/projects/AADJ-smokeping/dist/etc/config");
Smokeping::cgi("/smokeping/smokeping-2.3.6/etc/config");


配置 htdocs/cropper/*
用來作頁面圖像放大縮小的工具。


配置 etc/basepage.html
顯示頁面的主框架。裡面之需要配置"htdocs/cropper/"的位置即可。


配置 etc/config
# vi /smokeping/smokeping-2.3.6/etc/config
(config 默認是只讀的,需要修改屬性)
將以下幾行替換為已經安裝的相關軟體的路徑(將橙黃色改為淺黃色):

*** General ***
owner    = Peter Random
owner = qu6zhi.test (輸入您的名字,顯示在網頁上)

contact = some@address.nowhere
contact = user@domain (輸入您的郵件,顯示在網頁上)

imgcache = /home/oetiker/public_html/smokeping-ms/cache
imgcache = /smokeping/smokeping-2.3.6/htdocs/cache

imgurl   = cache
imgurl   = cache

datadir = /tmp/smokeping-ms/data
datadir = /smokeping/smokeping-2.3.6/var

piddir = /tmp/smokeping-ms/var
piddir = /smokeping/smokeping-2.3.6/var

cgiurl   = http://some.url/smokeping.cgi
cgiurl   = http://IP/htdocs/smokeping.cgi

smokemail = /home/oetiker/checkouts/smokeping/trunk/software/etc/smokemail.dist
smokemail = /smokeping/smokeping-2.3.6/etc/smokemail

tmail = /home/oetiker/checkouts/smokeping/trunk/software/etc/tmail.dist
tmail = /smokeping/smokeping-2.3.6/etc/tmail.dist

*** Presentation ***

template = /home/oetiker/checkouts/smokeping/trunk/software/etc/basepage.html.dist
template = /smokeping/smokeping-2.3.6/etc/basepage.html
*** Database ***
step     = 30 // web 頁面的刷新時間
pings    = 1000

*** Alerts ***
to = alertee@address.somewhere
to = user@domain (要收到報警郵件的 e-mail address)

from = smokealert@company.xy
from = smokealert@localhost (本機要發送的賬號)


*** Targets ***
編輯要做監控的主機
編輯方式采階層式, 用 + (加號) 做階層功能

probe = FPing
normal 是100bit
default 是 1024bit

+ Test

menu = Top
title = Network Latency Grapher(描述)

++ stddev(++ 第二層分類)
sorter = StdDev(entries=>4)
title = Top Standard Deviation
menu = Std Deviation(menu = 第二層)
format = Standard Deviation %f

title = 第二層的描述

+++ Switch001
menu = 第三層里的配置 (可以繼續分層)
title = 第三層里的設備的名稱
host = 192.168.1.254 (IP 或 domain name 都可以)
+++ Switch002
menu = 第三層里的設備 (可以繼續分層)
title = 第三層里的設備的名稱
host = 192.168.2.254 (IP 或 domain name 都可以)
menu = Multihost
title = James and James as seen from Boomer
host = /World/第二層分類/Switch001 /World/第二層分類/Switch002 (將多個圖合併到一個圖中)

*** Targets ***
probe = FPing

menu = Top
title = Network Latency Grapher
remark = Welcome to this SmokePing website.

+ mysite1
menu = Site 1
title = Hosts in Site 1

++ myhost1
host = myhost1.mysite1.example
++ myhost2
host = myhost2.mysite1.example

+ mysite2
menu = Site 2
title = Hosts in Site 2

++ myhost3
host = myhost3.mysite2.example
++ myhost4
host = myhost4.mysite2.example
注意:設備名字當中不能出現「.」。

*** Probes ***

+ FPing
binary = /usr/sbin/fping
binary = /smokeping/fping-2.4b2_to/fping


*** Slaves ***
secrets=/smokeping/smokeping-2.3.6/etc/smokeping_secrets.dist
#+boomer
#display_name=boomer
#color=0000ff
#+slave2

顯示中文
*** Presentation ***
中,加入:

charset = gb2312
不過 rrdtool 圖像中還是顯示不了中文。

最後:
# mkdir /smokeping/smokeping-2.3.6/htdocs/cache
# mkdir /smokeping/smokeping-2.3.6/var
===================================================================================

# vi /smokeping/smokeping-2.3.6/etc/config
確認下圖的配置
imgcache = /home/oetiker/public_html/smokeping-ms/cache
imgcache = /smokeping/smokeping-2.3.6/htdocs/cache

imgurl   = cache
imgurl   = cache

datadir = /tmp/smokeping-ms/data
datadir = /smokeping/smokeping-2.3.6/var

piddir = /tmp/smokeping-ms/var
piddir = /smokeping/smokeping-2.3.6/var

查看緩存 /smokeping/smokeping-2.3.6/htdocs/cache/HP-IDC/ 沒有發現 png 文件,這樣不正常。

給 smokeping 目錄 apache 完全許可權,不然 rrdtool 會畫不出圖:
# chown -R apache:apache /smokeping/smokeping-2.3.6/

imgurl (mandatory setting) Either an absolute URL to the imgcache directory or one relative to the directory where you keep the SmokePing cgi.
# vi /smokeping/smokeping-2.3.6/etc/config ……
#imgurl = /smokeping/smokeping-2.3.6/htdocs/cache imgurl = cache
……

===================================================================================
四、web 頁面認證的配置

# wget http://ftp.cuhk.edu.hk/pub/packa ... edyCGI-1.8.2.tar.gz

① 把運營設備 /var/www/.htaccess 拷貝到新設備的 /var/www 目錄下;

② 把運營設備 /smokeping/smokeping-2.3.6/etc/htpasswd.users 拷貝到新設備的 /smokeping/smokeping-2.3.6/etc 目錄下;如果考不過來,就在運營設備上 vi htpasswd.users ,同時在新設備上 vi /smokeping/smokeping-2.3.6/etc/htpasswd.users ,然後把運營設備的那個文件裡面的內容拷貝到新設備的那個文件里,(noc:bC6fBME.DZLHE)保存推出vi ;

③ 接下來配置 smokeping 的儲存圖形文件的目錄,不然會畫不出圖:
# mkdir /smokeping/smokeping-2.3.6/.simg
# chown -R apache:apache /smokeping/smokeping-2.3.6/

④ 接下來編輯 apache 的配置文件,讓apache能執行 smokeping 的 html 文件:
# vi /etc/httpd/conf/httpd.conf

NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot /smokeping/smokeping-2.3.6/htdocs
   ServerName dummy-host.example.com
   ScriptAlias /index.html /smokeping/smokeping-2.3.6/htdocs/smokeping.cgi
</VirtualHost>

把下面這段加到下面幾行配置下面
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

要加的配置是:
<Directory "/smokeping/smokeping-2.3.6/htdocs">
Options FollowSymLinks ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<Directory /smokeping/smokeping-2.3.6>
Options FollowSymLinks
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>

⑤ 然後,為了不讓 apache 找 mysql 去認證,需要:
# yum install mod_auth_mysql
===================================================================================
六、運行環境

刪除進程:
# cd /smokeping/smokeping-2.3.6/etc
# killall smokeping(多執行)
# ps -efH |grep smokeping

啟動進程:
# /smokeping/smokeping-2.3.6/bin/smokeping start
# service httpd restart
配置開機自動運行
# vi /etc/rc.d/rc.local
/smokeping/smokeping-2.3.6/bin/smokeping start
打開瀏覽器,
http://x.x.x.x/htdocs/smokeping.cgi

===================================================================================
七、訪問許可權
① 修改 httpd.conf
# vi /etc/httpd/conf/httpd.conf
306 <Directory "/smokeping/smokeping-2.3.6/htdocs">
307
308 #
309 # Possible values for the Options directive are "None", "All",
310 # or any combination of:
311 #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
312 #
313 # Note that "MultiViews" must be named *explicitly* --- "Options All"
314 # doesn't give it to you.
315 #
316 # The Options directive is both complicated and important.  Please see
317 # http://httpd.apache.org/docs/2.2/mod/core.html#options
318 # for more information.
319 #
320     Options Indexes FollowSymLinks
321
322 #
323 # AllowOverride controls what directives may be placed in .htaccess files.
324 # It can be "All", "None", or any combination of the keywords:
325 #   Options FileInfo AuthConfig Limit
326 #
327     AllowOverride AuthConfig
328
329 #
330 # Controls who can get stuff from this server.
331 #
332     Order allow,deny
333     Allow from all
334
335 </Directory> 意思是在 /smokeping/smokeping-2.3.6/htdocs 下不同目錄的訪問許可權由該目錄下的 .htaccess 文件來控制,而且不同目錄的許可權策略可互相覆蓋。
② 編輯 .htaccess 文件
# vi /smokeping/smokeping-2.3.6/htdocs/.htaccess.smoke #訪問許可權控制文件
AuthUserFile /smokeping/smokeping-2.3.6/htdocs/htpasswd.smoke.user   # 用戶密碼信息存放文件
AuthType Basic   #認證類型為基本型
AuthName "smokeping"  #彈出對話框的說明
require valid-user   #認證方式
保存退出。

③ 建立用戶
# /usr/bin/htpasswd –c  /smokeping/smokeping-2.3.6/htdocs/htpasswd.smoke.user admin # 建立用戶 admin
New password: # 輸入用戶密碼
Re-type new password: # 再次輸入密碼
Adding password for user admin # 添加用戶成功信息
可以建立多個用戶

④ # chgrp apache htpasswd.smoke.user
    # chmod 640 htpasswd.smoke.user

⑤ 重啟 apache,再次訪問http://xxx.xxx.xxx.xxx,這時應該出現一個身份認證窗口,你需要輸入用戶名和密碼才能訪問這個頁面。
如果你也遇到 Apache 還不支持 .htaccess 的情況,使用我上面的這個情況不行的話,那就在 httpd.conf 文件里搜索 LoadModule rewrite_module modules/mod_rewrite.so,如果前面有 # 符號,就去掉。保存,然後重啟 Apache 。
===================================================================================
285 vi /etc/bashrc
286 w
320 netstat -anptu
321 ps -A | grep smoke
===================================================================================
《解決方案》

{:3_198:}{:3_199:}{:3_200:}{:3_201:}

[火星人 ] 配置 SmokePing --轉已經有1267次圍觀

http://coctec.com/docs/service/show-post-2269.html