Install Smokeping
时间:2010-08-23 来源:hjjie2006
1)更改配置的源:
cd /etc/yum.repos.d/
wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo
【安装相关软件】
smokeping 是一个用 perl 写的程序,所以不需要安装。但是他需要使用一些工具以及 perl 的 module,还有 rrdtool、fping、echoping 等,这些都需要预先安装好。smokeping 启动的时候,也会自己去检查需要用到的程序是否能找到。
配置好了 yum后 :
# yum -y install freetype-devel zlib-devel libpng-devel libart_lgpl-devel
2关闭 selinux
# setenforce 0
或
# vi /etc/sysconfig/selinux
将 SELINUX=enforcing
改成 SELINUX=disabled
重启后生效
3).安装RRDTool
由于rrdtool-1.2.23需要一些库文件支持,故需先安装配置支持的环境,然后编译安装。直接运行以下bash脚本
就可以完成安装:
由于rrdtool-1.2.23需要一些库文件支持,故需先安装配置支持的环境,然后编译安装。直接运行以下bash脚本
就可以完成安装:
注意:将cgilib-0.5.tar.gz、zlib-1.2.3.tar.gz、libpng-1.2.18.tar.gz、freetype-2.3.5.tar.gz、
libart_lgpl-2.3.17.tar.gz、rrdtool-1.2.23.tar.gz放到/root/rrdtool-1.2.23目录下,将脚本保存
为/root/rrdtool-1.2.23/rrdtoolinstall.sh,并给执行权限chmod u+x
/root/rrdtool-1.2.23/rrdtoolinstall.sh
#!/bin/sh
BUILD_DIR=`pwd`
INSTALL_DIR=/usr/local/rrdtool
cd $BUILD_DIR
tar zxf cgilib-0.5.tar.gz
cd cgilib-0.5
make CC=gcc CFLAGS="-O3 -fPIC -I."
mkdir -p $BUILD_DIR/lb/include
cp *.h $BUILD_DIR/lb/include
mkdir -p $BUILD_DIR/lb/lib
cp libcgi* $BUILD_DIR/lb/lib
cd $BUILD_DIR
tar zxf zlib-1.2.3.tar.gz
cd zlib-1.2.3
env CFLAGS="-O3 -fPIC" ./configure --prefix=$BUILD_DIR/lb
make
make install
cd $BUILD_DIR
tar zxvf libpng-1.2.18.tar.gz
cd libpng-1.2.18
env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" \
./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
cd $BUILD_DIR
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.2.5
env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" \
./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
cd $BUILD_DIR
tar zxvf libart_lgpl-2.3.17.tar.gz
cd libart_lgpl-2.3.17
env CFLAGS="-O3 -fPIC" ./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
IR=-I$BUILD_DIR/lb/include
CPPFLAGS="$IR $IR/libart-2.0 $IR/freetype2 $IR/libpng"
LDFLAGS="-L$BUILD_DIR/lb/lib"
CFLAGS=-O3
export CPPFLAGS LDFLAGS CFLAGS
cd $BUILD_DIR
tar zxf rrdtool-1.2.23.tar.gz
cd rrdtool-1.2.23
./configure --prefix=$INSTALL_DIR --disable-python --disable-tcl && make && make install
//完成后建立符号连接
ln –s /usr/local/rrdtool/bin/* /usr/local/bin/
//执行rrdtool看是否安装正确
4. #Install httpd
useradd www
cd /usr/local/src
tar zxvf httpd-2.2.8.tar.gz
cd httpd-2.2.8
./configure --prefix=/usr/local/apache2 --enable-module=so --enable-rewrite
make && make install
5.#Install fping
wget http://fping.sourceforge.net/download/fping.tar.gz
#Install fping
cd /usr/local/src
tar zxvf fping.tar.gz
cd fping-2.4b2_to/
./configure
make && make install
6.#Install CGI-SpeedyCGI
wget http://daemoninc.com/SpeedyCGI/CGI-SpeedyCGI-2.22.tar.gz
#Install CGI-SpeedyCGI
cd /usr/local/src
tar -zxvf CGI-SpeedyCGI-2.22.tar.gz
cd CGI-SpeedyCGI-2.22
perl Makefile.PL
Compile mod_speedycgi (default no)? no
cd /usr/local/src
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
cd /usr/local/src/ CGI-SpeedyCGI-2.22
make && make install
7.#Install Perl modules libwww-perl
cd /usr/local/src
wget http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/libwww-perl-5.836.tar.gz
tar -zxvf libwww-perl-5.836.tar.gz
cd libwww-perl-5.836
perl Makefile.PL
make && make install
8. #Install smokeping
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.4.2.tar.gz
cd /usr/local/src
tar -zxvf smokeping-2.4.2.tar.gz
mv smokeping-2.4.2 /usr/local/smokeping
修改smokeping&httpd配置文件
mkdir -p /usr/local/smokeping/htdocs/img
mkdir -p /usr/local/smokeping/var
smokeping/bin下
cd /usr/local/smokeping/bin
mv smokeping.dist smokeping
修改smokeping文件
file: smokeping
use lib qw(/usr/lib/perl5);
use lib qw(/usr/local/smokeping/lib);
Smokeping::main("/usr/local/smokeping/etc/config");
重命名config文件
cd /usr/local/smokeping/etc
mv config.dist config
修改 config文件为以下内容(全部粘上来做参考)
[root@localhost etc]# cat config
*** General ***
owner = xiao hu
contact = [email protected]
mailhost = my.mail.host
sendmail = /usr/lib/sendmail
imgcache = /usr/local/smokeping/htdocs/img
imgurl = http://192.168.166.202/htdocs/img
datadir = /usr/local/smokeping/var
piddir = /usr/local/smokeping/var
cgiurl = http://192.168.166.202/htdocs/smokeping.cgi
smokemail = /usr/local/smokeping/etc/smokemail.dist
tmail = /usr/local/smokeping/etc/tmail.dist
# specify this to get syslog logging
syslogfacility = local0
# each probe is now run in its own process
# disable this to revert to the old behaviour
# concurrentprobes = no
*** Alerts ***
to = [email protected]
from = [email protected]
+someloss
type = loss
# in percent
pattern = >0%,*12*,>0%,*12*,>0%
comment = loss 3 times in a row
*** Database ***
step = 300
pings = 20
# consfn mrhb steps total
AVERAGE 0.5 1 1008
AVERAGE 0.5 12 4320
MIN 0.5 12 4320
MAX 0.5 12 4320
AVERAGE 0.5 144 720
MAX 0.5 144 720
MIN 0.5 144 720
*** Presentation ***
charset = gb2312
template = /usr/local/smokeping/etc/basepage.html.dist
+ charts
menu = Charts
title = The most interesting destinations
++ stddev
sorter = StdDev(entries=>4)
title = Top Standard Deviation
menu = Std Deviation
format = Stdandard Deviation %f
++ max
sorter = Max(entries=>5)
title = Top Max Roundtrip Time
menu = by Max
format = Max Roundtrip Time %f seconds
++ loss
sorter = Loss(entries=>5)
title = Top Packet Loss
menu = Loss
format = Packets Lost %f
++ median
sorter = Median(entries=>5)
title = Top Median Roundtrip Time
menu = by Median
format = Median RTT %f seconds
+ overview
width = 600
height = 50
range = 10h
+ detail
width = 600
height = 200
unison_tolerance = 2
"Last 3 Hours" 3h
"Last 30 Hours" 30h
"Last 10 Days" 10d
"Last 400 Days" 400d
*** Probes ***
+ FPing
binary = /usr/local/sbin/fping
#*** Slaves ***
#secrets=/usr/local/smokeping/etc/smokeping_secrets.dist
#+boomer
#display_name=boomer
#color=0000ff
#+slave2
*** Targets ***
probe = FPing
menu = Top
title = Network Latency Grapher
remark = Welcome to this SmokePing website.
+ mysite1
menu = IDC
title = Hosts
++ myhost1
host = www.baidu.com
++ myhost2
host = www.qq.com
++ myhost3
host = 192.168.0.1
修改smokeping.cgi
cd /usr/local/smokeping/htdocs
mv smokeping.cgi.dist smokeping.cgi
file:smokeping.cgi
use lib qw(/usr/lib/perl5/);
use lib qw(/usr/local/smokeping/lib);
Smokeping::cgi("/usr/local/smokeping/etc/config");
修改apache配置httpd.conf 加入以下内容
vim /usr/local/apache2/conf/httpd.conf
<VirtualHost *:80>
DocumentRoot /usr/local/smokeping
ServerName smokeing
AddHandler cgi-script .cgi
<Directory "/usr/local/smokeping/htdocs/">
AllowOverride None
Options ExecCGI Indexes
Order allow,deny
Allow from all
</Directory>
ErrorLog logs/ping-error_log
CustomLog logs/ping-access_log common
</VirtualHost>
chown -R daemon.daemon /usr/local/smokeping
修改smokeping运行权限daemon
然后,为了不让 apache 找 mysql 去认证,需要:
yum install mod_auth_mysql
启动
iptables -F
/usr/local/smokeping/bin/smokeping start
/usr/local/apache2/bin/apachectl start
报错解决
cp -rp /usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/*/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/
ps -ef|grep smokeping
ps –aux | grep http
访问
http://192.168.166.202/htdocs/smokeping.cgi
一个开源的smokeping 站点
http://oss.oetiker.ch/smokeping-demo/?target=Customers