#!/bin/bash#--variable Err_echo () { echo -e "\\033[31m[error]: $1 \\033[0m" exit 1}info_echo () { echo -e "\\033[32m [ info]: $1 \\033[0m "}warn_echo () { echo -e " \\033[33m [Warning]: $1 \\033[0m "}check_exit () { if [ $? -ne 0 ]; then err_echo "$" &NBSP;&NBSP;EXIT&NBSP;1&NBSP;&NBSP;&NBSP;&NBSP;FI} #配置yum源info_echo "Config yum source ..." rpm -uvh http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/rpms/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 1>/dev/nullinfo_echo "Setup tool pakeages ..." yum -y install wget 1>/dev/nullyum -y install perl perl-net-telnet perl-net-dns perl-ldap perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-cgi-speedcgi perl-time-hires perl-extutils-makemaker perl-rrd-simple rrdtool rrdtool-perl curl fping echoping httpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pango pango-devel freetype Freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_ fastcgi 1>/dev/nullif [ -f /root/smokeping-2.6.9.tar.gz ]; then warn_echo "/root/smokeping-2.6.9.tar.gz is exist" else info_echo "Download smokeping ..." wget http:// Oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz 1>/dev/nullficheck_exitif [ -f /usr /local/src/smokeping-2.6.9&nbSP;]; then rm -rf /usr/local/src/ smokeping-2.6.9fiinfo_echo "TAR&NBSP;SMOKEPING&NBSP;TO&NBSP;/USR/LOCAL/SRC" tar -xvf smokeping-2.6.9.tar.gz -c /usr/local/src 1>/dev/nullif [ -f /usr/local/smokeping ]; then mv /usr/local/smokeping smokeping_backficd /usr/local/src/smokeping-2.6.9info_echo "Set up smokeping ..."./ Configure -prefix=/usr/local/smokeping 1>/dev/nullif [ $? -ne 0 ];thenecho -e "\\033[33m first setup faild \\033[0m" info_echo " Per handle symbiosis ... "./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty 1>/dev/nullinfo_echo "Full install smokeping ..." ./configure -prefix =/usr/local/smokeping 1>/dev/null/usr/bin/gmake install 1>/dev/nullelse/usr/bin/gmake install 1>/dev/nullcheck_exitficd /usr/local/smokepingmkdir cache data var 1>/dev /nullcheck_exitinfo_echo "Chomod dir permission" #修改目录权限chown -R apache:apache cache data varchown -r apache:apache /var/log/smokeping.logmv /usr/local/ smokeping/htdocs/smokeping.fcgi.dist /usr/local/smokeping/htdocs/smokeping.fcgimv /usr/local/ smokeping/etc/config.dist /usr/local/smokeping/etc/configcp -f /usr/local/smokeping/etc/ config /usr/local/smokeping/etc/config.backinfo_echo "Edit smokeping config ..." Modify the smokeping configuration file ip= '/sbin/ifconfig|sed -n '/inet addr/s/^[^:]*:\ ([0-9.] \{7,15\}\) .*/\1/1p ' |sed -n ' 1p ' sed -i "/cgiurl/c cgiurl = http:\/\/$ ip/smokeping.cgi " /root/configsed -i "/Imgurl/c imgurl = http:\/\/$IP/cache " /root/configchmod 600 /usr/local/ smokeping/etc/smokeping_secrets.distinfo_echo "Edit httpd config ..." #修改apache配置文件cp &NBSP;-RF /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.backcat >> /etc/httpd/ conf/httpd.conf << ' EOF ' alias /cache "/usr/local/smokeping/cache/" Alias /cropper "/usr/local/smokeping/htdocs/cropper/" alias /smokeping "/usr/local/smokeping/htdocs/ smokeping.fcgi "<Directory "/usr/local/smokeping ">allowoverride noneoptions alladdhandler cgi-script .fcgi .cgiOrder allow,denyAllow from allDirectoryIndex smokeping.fcgi</directory>eof# provides a startup script info_echo "Edit auto manger script" if [ -f /etc/init.d/smokeping ];then warn_echo "/etc/init.d/smokeping is exist "Else touch /etc/init.d/smokeping cat > /etc/init.d/smokeping < < ' EOF ' #!/bin/bash#chkconfig: 2345 80 05 # description: smokeping init.d script # create by : mox # get function from functions library . /etc/init.d/functions # Start the service smokepingsmokeping=/usr/local/smokeping/bin/smokepingprog=smokepingpidfile=${pidfile-/usr/local/smokeping/var/ smokeping.pid}lockfile=${lockfile-/var/lock/subsys/smokeping}retval=0stop_timeout=${stop_timeout-10}log=/var/ Log/smokeping.logstart () { echo -n $ "Starting $prog: " lang= $HTTPD _lang daemon --pidfile =${pidfile} $smokeping $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL} # Restart the service smokepingstop () { echo -n $ "stopping $prog: " killproc -p ${pidfile} -d ${STOP_TIMEOUT} $smokeping retval=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}} case "$" in start) start;; stop) stop;; status) status -p ${pidfile} $HTTPD RETVAL=$?;; restart) stop start ;; *) echo $ "usage: $prog {start|stop|restart |status} " retval=2esaceofchmod +x /etc/init.d/ smokepingchkconfig smokeping onfiif [ $? -ne 0 ];thenecho -e "\ \ 033[32m smokeping setup successfull \\033[0m "fi
This article is from the "left-handed" blog, make sure to keep this source http://mofeihu.blog.51cto.com/1825994/1782239
Network quality monitoring software smokeping One-click installation script