脚本安装smokeping-创新互联-成都快上网建站

脚本安装smokeping-创新互联

我将提供两种方法来安装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"

AllowOverride None
AddHandler cgi-script cgi
Options ExecCGI


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

[ "$?" -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

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前名称:脚本安装smokeping-创新互联
分享链接:http://kswjz.com/article/ceisds.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流