我將提供兩種方法來安裝smokeping,一種是大家常用的普通安裝,另一種是用腳本下自動化安裝的,僅供大家學習,參考!
普通安裝:
centos 5.4下安裝smokeping
需要的軟件:
(1)httpd
(2)rrdtool
(3)smokeping
(4)fping
(5)libwww-perl
安裝rrdtool前的準備工作
/etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1
yum? -y install? freetype-devel zlib-devel libpng-devel libart_lgpl-devel rrdtool
#Install httpd
useradd www
tar zxvf httpd-2.2.15.tar.gz
cd httpd-2.2.15
./configure --prefix=/usr/local/apache2 --enable-so
make && make install
wget http://fping.sourceforge.net/download/fping.tar.gz
#Install fping
tar zxvf fping.tar.gz
cd fping-2.4b2_to/
./configure?
make && make install?
wget http://daemoninc.com/SpeedyCGI/CGI-SpeedyCGI-2.22.tar.gz
#Install CGI-SpeedyCGI
tar –zxvf CGI-SpeedyCGI-2.22.tar.gz
cd CGI-SpeedyCGI-2.22
perl Makefile.PL
Compile mod_speedycgi (default no)? no
make && make install
#Install Perl modules libwww-perl
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
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.4.2.tar.gz
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下
mv smokeping.dist smokeping
file: smokeping
use lib qw(/usr/lib/perl5);
use lib qw(/usr/local/smokeping/lib);
Smokeping::main("/usr/local/smokeping/etc/config");
smokeping/etc
mv config.dist config
file:config
*** General ***
owner??? = Peter Random
contact? = some@address.nowhere
mailhost = my.mail.host
#sendmail = /usr/lib/sendmail
# NOTE: do not put the Image Cache below cgi-bin
# since all files under cgi-bin will be executed ... this is not
# good for p_w_picpaths.
imgcache = /usr/local/smokeping/htdocs/img
imgurl?? = http://本機IP/img?
datadir? = /usr/local/smokeping/var
piddir? = /usr/local/smokeping/var
cgiurl?? = http://本機IP/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 = alertee@address.somewhere
from = smokealert@company.xy
+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 ***
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 = Standard 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
#+ hierarchies
#++ owner
#title = Host Owner
#++ location
#title = Location
*** Probes ***
+ FPing
binary = /usr/local/sbin/fping
*** Slaves ***
secrets=/usr/local/smokeping/etc/smokeping_secrets.dist
+boomer
display_name=boomer
color=0000ff
+slave2
display_name=another
color=00ff00
*** Targets ***
probe = FPing
menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of xxx Company. \
???????? Here you will learn all about the latency of our network.
+ 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
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");
httpd添加如下
ScriptAlias /smokeping.cgi "/usr/local/smokeping/htdocs/smokeping.cgi"
alias /img "/usr/local/smokeping/htdocs/img"
<Directory "/usr/local/smokeping ">
AllowOverride None
AddHandler cgi-script cgi
Options ExecCGI
</Directory>
chown -R www.www /usr/local/smokeping
修改httpd.conf運行權限www
啟動
service iptables stop
/usr/local/smokeping/bin/smokeping start
/usr/local/apache2/bin/apachectl start
ps -ef|grep smokeping
腳本自動化安裝:
注意:在這里有些配置需要本身就有的。
如,我這個包里分auto_install_smokeping.sh和soft文件夾,soft文件夾下有smokeping,apache2,yum文件夾,而這些文件夾下又有一些文件,總架構如下:
auto_install_smokeping.sh
???????????????????????????????????????????????????????????????????????????????????? ---bin/smokeping
????????????????????????????????????????????????????? ---smokeping?????? ----etc/config
?????????????????????????????????????????????????????????????????????????????????????? ----htdocs/smokeping.cgi
soft??????????????????????????????????????????????? ---apache2??????????? ----conf/httpd.conf
?????????????????????????????????????????????????????? ---yum/dag.repo
?????????????????????????????????????????????????????? fping.tar.gz?? httpd-2.2.15.tar.gz等
?
腳本:
#!/bin/bash
#User Zhuzhengjun
#date 2010-06-28
#install need root user.
if [ `whoami` != "root" ];then
??????? echo "Installtion this package needs root user."
??????? exit 1
fi
#set env
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
export PATH
PWD=`pwd`
export PWD
mkdir -p logs
export LOG_FILE="$PWD/logs/install.log"
export ERROR_FILE="$PWD/logs/error.log"
export Soft="$PWD/soft"
#add user
echo "==========Add user==========" >>$LOG_FILE
echo "==========Add user==========" >>$ERROR_FILE
if [ `grep ^www /etc/passwd|wc -l` -eq 0 ] ;then
useradd www 1>> $LOG_FILE 2>> $ERROR_FILE
#echo "wokaosiquba"|passwd --stdin www 1>> $LOG_FILE 2>> $ERROR_FILE
else echo "www user is add!"
fi
#add dns
echo "==========Add dns==========" >>$LOG_FILE
echo "==========Add dns==========" >>$ERROR_FILE
if [ `grep "202.96.209.5" /etc/resolv.conf |wc -l ` -eq 0 ] ;then
echo "nameserver 202.96.209.5" >> /etc/resolv.conf 1>> $LOG_FILE 2>> $ERROR_FILE
fi
#add yum repos for rrdtool
echo "==========Add yum repos==========" >>$LOG_FILE
echo "==========Add yum repos==========" >>$ERROR_FILE
cp -f $Soft/yum/dag.repo /etc/yum.repos.d/ 1>> $LOG_FILE 2>> $ERROR_FILE
#install rrdtool wget cron ntp
echo "==========install rrdtool wget cron ntp==========" >>$LOG_FILE
echo "==========install rrdtool wget cron ntp==========" >>$ERROR_FILE
yum -y install ntp freetype-devel zlib-devel libpng-devel wget vixie-cron rrdtool 1>> $LOG_FILE 2>> $ERROR_FILE
if [ `grep "NTP_IP" /var/spool/cron/root |wc -l` -eq 0 ];then
echo "1 * * * * /usr/sbin/ntpdate NTP_IP; hwclock -w 1>/dev/null 2>&1" >> /var/spool/cron/root
fi
#install httpd
echo "==========Install httpd==========" >>$LOG_FILE
echo "==========Install httpd==========" >>$ERROR_FILE
cd $Soft
tar zxf httpd-2.2.15.tar.gz
cd httpd-2.2.15/
./configure --prefix=/usr/local/apache2 --enable-so 1>> $LOG_FILE 2>> $ERROR_FILE
[ "$?" -eq 0 ] && make 1>> $LOG_FILE 2>> $ERROR_FILE
[ "$?" -eq 0 ] && make install 1>> $LOG_FILE 2>> $ERROR_FILE
#install fping
echo "==========Install fping==========" >>$LOG_FILE
echo "==========Install fping==========" >>$ERROR_FILE
cd $Soft/
tar -zxf fping.tar.gz
cd fping-2.4b2_to/
./configure 1>> $LOG_FILE 2>> $ERROR_FILE
[ "$?" -eq 0 ] && make 1>> $LOG_FILE 2>> $ERROR_FILE
[ "$?" -eq 0 ] && make install 1>> $LOG_FILE 2>> $ERROR_FILE
#install CGI-SpeedyCGI
echo "==========Install CGI-SpeedyCGI==========" >>$LOG_FILE
echo "==========Install CGI-SpeedyCGI==========" >>$ERROR_FILE
cd $Soft/
tar -zxf CGI-SpeedyCGI-2.22.tar.gz
cd CGI-SpeedyCGI-2.22/
perl Makefile.PL <<END
END
[ "$?" -eq 0 ] && make 1>> $LOG_FILE 2>> $ERROR_FILE
[ "$?" -eq 0 ] && make install 1>> $LOG_FILE 2>> $ERROR_FILE
#install libwww-perl
echo "==========Install libwww-perl==========" >>$LOG_FILE
echo "==========Install libwww-perl==========" >>$ERROR_FILE
cd $Soft/
tar -zxf libwww-perl-5.836.tar.gz
cd libwww-perl-5.836/
perl Makefile.PL 1>> $LOG_FILE 2>> $ERROR_FILE
make 1>> $LOG_FILE 2>> $ERROR_FILE
make install 1>> $LOG_FILE 2>> $ERROR_FILE
#install smokeping
echo "==========Install smokeping==========" >>$LOG_FILE
echo "==========Install smokeping==========" >>$ERROR_FILE
cd $Soft/
tar -zxf smokeping-2.4.2.tar.gz
mv smokeping-2.4.2 /usr/local/smokeping 1>> $LOG_FILE 2>> $ERROR_FILE
mkdir -p /usr/local/smokeping/htdocs/img
mkdir -p /usr/local/smokeping/var
#config smokeping
echo "==========Config smokeping==========" >>$LOG_FILE
echo "==========Config smokeping==========" >>$ERROR_FILE
cp -f $Soft/smokeping/bin/smokeping /usr/local/smokeping/bin/ 1>> $LOG_FILE 2>> $ERROR_FILE
cp -f $Soft/smokeping/etc/config /usr/local/smokeping/etc/ 1>> $LOG_FILE 2>> $ERROR_FILE
cp -f $Soft/smokeping/htdocs/smokeping.cgi /usr/local/smokeping/htdocs/ 1>> $LOG_FILE 2>> $ERROR_FILE
cp -f $Soft/apache2/conf/httpd.conf /usr/local/apache2/conf/ 1>> $LOG_FILE 2>> $ERROR_FILE
#authorize
echo "==========authorize==========" >>$LOG_FILE
echo "==========authorize==========" >>$ERROR_FILE
chown -R www.www /usr/local/smokeping?
chmod 400 /usr/local/smokeping/etc/smokeping_secrets.dist
chmod +x /usr/local/smokeping/bin/smokeping
chmod +x /usr/local/smokeping/htdocs/smokeping.cgi
#start deamon
echo "==========start deamon==========" >>$LOG_FILE
echo "==========start deamon==========" >>$ERROR_FILE
/usr/local/smokeping/bin/smokeping start? 1>> $LOG_FILE 2>> $ERROR_FILE
/usr/local/apache2/bin/apachectl start 1>> $LOG_FILE 2>> $ERROR_FILE
service iptables stop
ps -ef|grep smokeping
轉載于:https://blog.51cto.com/ghostxyj/1962323