一直用nagios做网络监控报警,最近才知道还有个SmokePing,一看作者是RRD的作者,于是决定下来试用一下。
首先系统安装环境,虚拟机下安装CentOS6.3,32位的,SmokePing从官网下载的2.6.8,旧版本拷贝就能用,新版本已经变成需要安装的了,不过也更简单容易了。
安装系统的时候直接把apache和编译工具都装了,省得再装了,如果没装的需要再装一下,反正也就一条命令。
首先先安装一些依赖包,输入以下命令

yum -y install httpd-devel libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel

安装rrdtool 1.4.7

 wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz
 tar zxvf rrdtool-1.4.7.tar.gz
 cd rrdtool-1.4.7
 ./configure --prefix=/usr/local/rrdtool
 make && make install

安装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

安装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

安装FCGI

 wget http://cpan.communilink.net/authors/id/F/FL/FLORA/FCGI-0.74.tar.gz
 tar zxvf FCGI-0.74.tar.gz
 cd FCGI-0.74
 perl Makefile.PL
 make && make install

安装mod_fastcgi,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
 apxs -o mod_fastcgi.so -c *.c
 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.8.tar.gz
tar zxvf smokeping-2.6.8.tar.gz
./configure --prefix=/usr/local/smokeping

在这里会得到类似如下错误提示,需要安装perl一些依赖包

 checking checking for perl module 'RRDs'... Failed
 checking checking for perl module 'FCGI'... Ok
 checking checking for perl module 'CGI'... Ok
 checking checking for perl module 'CGI::Fast'... Ok
 checking checking for perl module 'Config::Grammar'... Failed
 checking checking for perl module 'Digest::HMAC_MD5'... Failed
 checking checking for perl module 'LWP'... Ok

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

先解决”checking checking for perl module ‘RRDs’… Failed”的问题,由于我们是编译安装的rrdtool,所以perl没找到默认路径下它的模块,需要手工拷贝过去

cp /usr/local/rrdtool/lib/perl/5.10.1/i386-linux-thread-multi/RRDs.pm /usr/lib/perl5/
cp /usr/local/rrdtool/lib/perl/5.10.1/i386-linux-thread-multi/auto/RRDs/RRDs.so /usr/lib/perl5/

如果你是CentOS5.9,就是下面的命令,perl版本不同

cp /usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/RRDs.pm /usr/lib/perl5/5.8.8/i386-linux-thread-multi/
cp /usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/auto/RRDs/RRDs.so /usr/lib/perl5/5.8.8/i386-linux-thread-multi/

下面的几个模块在错误提示中已经提到解决办法,运行以下指令就会自动下载安装了

./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty

装完之后,重新运行下面指令

./configure --prefix=/usr/local/smokeping
gmake install

配置smokeping

 cd /usr/local/smokeping/
 mkdir cache data var
 chown apache.apache cache data var
 cd /usr/local/smokeping/htdocs/
 cp smokeping.fcgi.dist smokeping.fcgi
 cd /usr/local/smokeping/etc/
 cp config.dist config
 chmod 400 /usr/local/smokeping/etc/smokeping_secrets.dist
 ln -s /usr/local/smokeping/cache /usr/local/smokeping/htdocs/cache

修改/usr/local/smokeping/etc/config

vi /usr/local/smokeping/etc/config
找到binary = /usr/sbin/fping
修改为binary = /usr/local/sbin/fping
 /usr/local/sbin/fping

修改/usr/local/smokeping/bin/smokeping

vi /usr/local/smokeping/bin/smokeping
找到:use lib qw(); # PERL5LIB
修改为:use lib qw(/usr/local/rrdtool/lib/perl); # PERL5LIB

修改主机配置文件,增加自己的主机,如果只想测试就把host改成自己要检测的IP就行了

+ Test
 menu= Targets
 #parents = owner:/Test/James location:/

 ++ James

 menu = James
 title =James
 alerts = someloss
 slaves = boomer slave2
 host = james.address

 ++ MultiHost

 menu = Multihost
 title = James and James as seen from Boomer
 host = /Test/James /Test/James~boomer

创建开机自动运行脚本
vi /etc/rc.local
写入如下内容

nohup /usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &

修改apache配置文件

Alias /smokeping/ "/usr/local/smokeping/htdocs/"
AllowOverride None Options All AddHandler cgi-script .fcgi .cgi Order allow,deny Allow from all DirectoryIndex smokeping.fcgi 

最后重器apache服务,运行

nohup /usr/local/smokeping/bin/smokeping –logfile=/var/log/smokeping.log 2>&1 &

打开浏览器输入http://smokeping-ip/smokeping/即可访问

标签: none

添加新评论