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./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./wish and
place an order.
-- Tobi Oetiker
<tobi@>
----------------------------------------------------------------
# make
# make install
# whereis
rrdtool
rrdtool:
/usr/local/rrdtool
完成后执行cd ..退回安装包的目录
------------------------------------------------------------------------------------------------------------------------------------
【cgilib】
# wget
http://down1./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./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./project/echoping/echoping/6.0.0/echoping-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:///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/5/i386/mod_speedycgi-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/5Server/i386/perl-CGI-SpeedyCGI-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./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./pub/packages/perl/CPAN/authors/id/H/HO/HORROCKS/CGI-SpeedyCGI-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./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://.,这
时应该出现一个身份认证窗口,你需要输入用户名和密码才能访问这个页面。
如果你也遇到 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
===================================================================================
参考:
官方:http://oss./smokeping/
官方:http://oss./smokeping/doc/smokeping_config.en.html
https://confluence.slac./display/IEPM/Smokeping+Installation
http://blog.sina.com.cn/s/blog_58d6275e01000a5s.html
http://hi.baidu.com/qu6zhi/blog/item/e80633dc3e8926a8cd1166ab.html
http://www./ruoyoux/articles/257138.html
http://linux./bbs/thread-1064864-1-1.html
http://bbs./read.php?tid=98204&uid=12891
http://search./~horrocks/CGI-SpeedyCGI-2.22/
http://search./~horrocks/CGI-SpeedyCGI-2.22/lib/CGI/SpeedyCGI.pm
http:///SpeedyCGI/
http://search./~horrocks/CGI-SpeedyCGI-2.22/src/SpeedyCGI.src
http://pzc./?p=282
http://www./apache-htaccess/
http://blog.sina.com.cn/s/blog_5398c3200100b4in.html~type=v5_one&label=rela_nextarticle
http://www./smokeping/probe/TelnetJunOSPing.en.html
http://hi.baidu.com/qu6zhi/blog/item/41eae42e3f455e594fc226a7.html
http://blogs.techrepublic./networking/?p=334
Install Smokeping on
openBSD:http://idur.staff./tag/smokeping/page/2/
http://blog.sina.com.cn/s/blog_6151984a0100euux.html###
http://www./user/lindahu/blog/2005/04/26/1502/5188/
http://www./user/lindahu/blog/2005/12/20/1502/18268/
http://bbs./viewthread.php?tid=678582&page=1
感谢:吴晓晨
转自:http://hi.baidu.com/qu6zhi/blog/item/b920561649490c58f3de329d.html