创建日期:2011/12/07
修改日期:2011/12/08
email:[email protected]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
前几天公司需要搭建个smokeping服务监控各个机房的网络情况,在网上找了几篇安装文档发现使用的版本都比较老,主要以2.4.2和2.3.6为主,而2.6版与老版本亦有所差别,写一篇最新版本的安装说明,希望能给有需要的兄弟一点帮助。
我在自己的环境下安装了5遍以上,由于各位系统环境可能有所差异,如遇到问题欢迎mail给我共同探讨。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
【Smokeping 简介】
是 rrdtool 的作者 Tobi Oetiker 的作品,所以它在图形显示方面有很大优势,也是一个很有特点的 opensource 工具:
多种探测方式,包括 fping、echoping、dig、curl 等;
易用可扩展的插件;
master/slave 的工作方式,可以在多个节点收集同一个监测点的数据;
很有特色的 alert 设置,不只是简单的设置一个阀值。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
一、系统centos5.6
[root@localhost src]# uname -a
Linux localhost.localdomain 2.6.18-274.3.1.el5 #1 SMP Tue Sep 6 20:13:52 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost Test]# perl -v
This is perl, v5.8.8 built for x86_64-linux-thread-multi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
二、准备工作
1、请先暂时关闭iptables以及selinux刨除其他影响
/etc/init.d/iptables stop
/etc/init.d/ip6tables stop
setenforce 0
或者
vi /etc/sysconfig/selinux
将 SELINUX=enforcing
改成 SELINUX=disabled
重启后生效
2、更新一下yum源,国内用163的吧。
cd /etc/yum.repos.d/
mv CentOS-Base.repo{,.bak}
wget http://mirrors.163.com/.help/CentOS-Base-163.repo
重新生成下缓存
yum makecache
前期准备工作到此为止;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
三、安装apache与smokeping
1、首先安装web服务器,apache/nginx都可,我选用apache
下载apache
cd /usr/local/src
首先安装openssl以支持apache的ssl
yum –y install openssl*
wget http://mirrors.sohu.com/apache/httpd-2.2.21.tar.bz2
tar jxvf httpd-2.2.21.tar.bz2
cd httpd-2.2.21
./configure --prefix=/usr/local/apache2 --enable-so --enable-ssl --enable-rewrite --enable-deflate
make && make install
2、Apache先放着吧,接下来安装rrdtool,
官方文档写的最低1.2版本,到此文结束为止,rrdtool最新版本为1.4.5
(1)rrdtool所依赖的库
我的系统是centOs 所以就yum安装
yum -y install libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel
如果不能yum的 请下载以上的tar包 编译安装。
(2)rrdtool的具体安装
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.5.tar.gz
tar zxvf rrdtool-1.4.5.tar.gz
cd rrdtool-1.4.5
./configure --prefix=/usr/local/rrdtool --disable-tcl --disable-python
make && make install
(3).RRDTOOL安装后验证
/usr/local/rrdtool/bin/rrdtool -v
出现以下RRDTOOL的信息就已经成功了
RRDtool 1.4.5 Copyright 1997-2010 by Tobias Oetiker
Compiled Dec 9 2011 00:29:16
Usage: rrdtool [options] command command_options
Valid commands: create, update, updatev, graph, graphv, dump, restore,
last, lastupdate, first, info, fetch, tune,
resize, xport, flushcached
RRDtool is distributed under the Terms of the GNU General
Public License Version 2. (www.gnu.org/copyleft/gpl.html)
For more information read the RRD manpages
切忌,安装完一定要验证,不一定安装完成后就是成功的。
以上rrdtool1.4安装方法摘自http://www.lvtao.net/html/824.html并多次测试成功
3、Smokeping安装
官方文档http://oss.oetiker.ch/smokeping/doc/smokeping_install.en.html
参考文档http://www.cnblogs.com/cellibate17/
http://bbs.linuxtone.org/thread-10409-1-1.html
http://loneblog.com/blog/cant-locate-rrds-pm.html
http://zhougx.72pines.com/page/2/
http://www.cnblogs.com/cellibate17/archive/2011/12/7.html
http://www.hksilicon.com/kb/cn/articles/41769/Smokeping-Cant-locate-RRDspm-in-INC
http://hi.baidu.com/rhca/blog/item/51c67bcfe0d5d333f9dc6178.html
下面安装cgilib、fping、echoping
【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
[root@localhost ~]# whereis fping
fping: /usr/local/sbin/fping
【echoping】
wget http://jaist.dl.sourceforge.net/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 --without-libidn
make
make test
遇到测试不成功等信息就 ctrl+c 回到命令行;
make install
[root@localhost ~]# whereis echoping
echoping: /usr/local/bin/echoping /usr/local/lib/echoping
【FCGI】
wget http://cpan.communilink.net/authors/id/F/FL/FLORA/FCGI-0.74.tar.gz
tar zxvf FCGI-0.74.tar.gz
cd cd FCGI-0.74
perl Makefile.PL
make && make install
【mod_fastcgi】apache dso方式
wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz
tar zxvf mod_fastcgi-2.4.6.tar.gz
cd mod_fastcgi-2.4.6
/usr/local/apache2/bin/apxs -o mod_fastcgi.so -c *.c
/usr/local/apache2/bin/apxs -i -a -n fastcgi .libs/mod_fastcgi.so
修改apache配置文件 :确认有如下一行,没有则添加
LoadModule fastcgi_module modules/mod_fastcgi.so
【smokeping】
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.6.tar.gz
tar zxvf tar zxvf smokeping-2.6.6.tar.gz
cd smokeping-2.6.6
./configure --prefix=/usr/local/smokeping
这里出错了,看一下报错信息:
checking checking for gnu make availablility... /usr/bin/gmake is GNU make
checking checking for perl module 'RRDs'... OK
checking checking for perl module 'FCGI'... Failed
checking checking for perl module 'CGI'... Ok
checking checking for perl module 'CGI::Fast'... Failed
checking checking for perl module 'Config::Grammar'... Failed
checking checking for perl module 'Digest::HMAC_MD5'... Failed
checking checking for perl module 'LWP'... Failed
** 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
直接执行脚本,接下来就是在线等……..来看下脚本的内容
vim setup/build-perl-modules.sh
#!/bin/bash
. `dirname $0`/sdbs.inc
for module in \
FCGI \
CGI \
CGI::Fast \
Config::Grammar \
Digest::HMAC_MD5 \
Net::Telnet \
Net::OpenSSH \
Net::SNMP \
Net::LDAP \
Net::DNS \
IO::Pty \
LWP \
; do
perlmodule $module
done
还个办法就是上yum吧,直接yum –y install perl-[FAIL-MOUDLES],如果出现找不到相应包的情况,就辛苦点www.cpan.org去下载安装吧
### checking checking for perl module 'RRDs'... Failed 的解决方法
32位:cp -rf /usr/local/rrdtool/lib/perl5/5.8.8/i386-linux-thread-multi/ /usr/lib/perl5/5.8.8/i386-linux-thread-multi/
64位:cp -rf /usr/local/rrdtool/lib/perl/5.8.8/x86_64-linux-thread-multi/ /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi
make clean
重新configure
./configure –prefix=/usr/local/smokeping
gmake install
安装成功会产生以下几个目录
[root@localhost smokeping]# ls /usr/local/smokeping/
bin etc htdocs lib share thirdparty
进入bin目录,修改smokeping文件#vim smokeping
第八行: use lib qw(); # PERL5LIB
修改为: use lib qw(/usr/local/rrdtool/lib/perl);
进入htdocs目录
mv smokeping.fcgi.dist smokeping.fcgi
进入etc目录
cp config.dist config
修改config文件
vim config
以下自行修改为自己需要的
owner =
contact =
mailhost =
cgiurl = http://192.168.6.135/smokeping (此为smokeping的http访问路径)
修改报警邮箱
*** Alerts ***
to = [email protected]
from = [email protected]
*** Probes ***
+ FPing
binary = /usr/sbin/fping##修改为实际路径
binary = /usr/local/sbin/fping
监控主机是分层结构的,用+号表示
例如+第一层 ++第二层 +++第三层 根据自己情况修改,附件有示例配置,比较简单
在这里,设备名中不能有"."
#####master/slave方式、报警以及其他的一些功能将在后续补充
创建存放数据文件的目录
mkdir /usr/local/smokeping/data /usr/local/smokeping/var /usr/local/smokeping/cache
修改smokeping的目录为apache运行用户的属主、组
chown -R daemon.daemon smokeping/
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
创建smokeping的log文件
touch /var/log/smokeping.log
chown daemon.daemon /var/log/smokeping.log
启动smokeping
perl /usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log
配置apache,再加个认证吧
vim /usr/local/apache2/conf/httpd.conf
最后加入
Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"
Alias /cache "/usr/local/smokeping/cache"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
AllowOverride None
AddHandler cgi-script cgi fcgi
Options ExecCGI
Order allow,deny
Allow from all
AuthName "Smokeping Access"
AuthType Basic
AuthUserFile /usr/local/smokeping/etc/htpasswd.users
Require valid-user
创建个用户名密码
/usr/local/apache2/bin/htpasswd -c /usr/local/smokeping/etc/htpasswd.users test
修改下权限:chown daemon.deamon /usr/local/smokeping/etc/htpasswd.users
好了,至此安装配置完成,启动apache
访问http://IP/smokeping
###其实apache的配置多种多样,看你个人喜欢了,以下再提供一种更简便的配置
1、修改/usr/local/smokeping/etc/config
第十行 imgcache = /usr/local/smokeping/cache
改为 imgcache = /usr/local/smokeping/htdocs/cache
2、创建/usr/local/smokeping/htdocs/cache目录并修改相应权限
mkdir /usr/local/smokeping/htdocs/cache
chown -R deamon.daemon /usr/local/smokeping/htdocs/cache
3修改apache配置文件,添加
vim /usr/local/apache2/conf/httpd.conf
Alias /smokeping "/usr/local/smokeping/htdocs/"
AllowOverride None
AddHandler cgi-script cgi fcgi
Options ExecCGI
Order allow,deny
Allow from all
DirectoryIndex smokeping.fcgi
AuthName "Smokeping Access"
AuthType Basic
AuthUserFile /usr/local/smokeping/etc/htpasswd.users
Require valid-user
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
四、不出图的解决思路(个人总结)、
(1)、可以使用--debug方式启动smokeping看是否有问题
(2)、查看smokeping日志
(3)、查看http的error.log,很多情况可以告诉你出错的地方
(4)、查看文件权限
a、data文件夹是否可写
b、data文件夹下是否有你所创建监控主机的目录,以本例来说就是Test,查看是否可写
c、Test文件下是否有你所创建的设备名的.rrd文件,本例中为(James.rrd)
d、可以看下James.rrd是否会5分钟更新一次(mtime)
e、查看htdocs/cache文件夹权限 (主、组为apache运行用户主、组,默认下权限为755)
f、启动smokeping后查看cache文件夹内是否有rrdtool.png smokeping.png两个图片
g、查看htdocs/cache下是否有你所创建的设备目录,本例中为Test并确定文件夹权限以及可写
h、查看htdocs/cache/Test下是否有。png图片并且会定时更新,如果没有一般为权限问题。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
纵坐标的u-----微秒
1秒=1000毫秒
1毫秒=1000微秒