Centos安装smokeping教程

Centos安装smokeping教程

 

一 .安装基本依赖包

ntpdate time.windows.com

#64bit
rpm -Uhv http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

#32bit
#rpm -Uhv http://apt.sw.be/redhat/el6/en/i386/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.i686.rpm

#install
yum -y install rrdtool fping echoping curl bind-utils 
yum -y install httpd 
yum -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 gcc wget perl-CPAN perl-devel perl-FCGI perl-CGI rrdtool-perl

 

二.smokeping编译安装

wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz
tar zxvf smokeping-2.6.9.tar.gz
cd smokeping-2.6.9

./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
./configure --prefix=/usr/local/smokeping
/usr/bin/gmake install


#copy file
cp /usr/local/smokeping/etc/config.dist /usr/local/smokeping/etc/config
cp /usr/local/smokeping/htdocs/smokeping.fcgi.dist /usr/local/smokeping/htdocs/smokeping.fcgi

#create directorys
mkdir -p /usr/local/smokeping/cache /usr/local/smokeping/data /usr/local/smokeping/var
chown -R apache.apache /usr/local/smokeping/cache /usr/local/smokeping/data /usr/local/smokeping/var

#create log file
touch /var/log/smokeping.log
chown apache.apache /var/log/smokeping.log

 

三.配置apache和基本验证

echo '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 None
        Options All
        AddHandler cgi-script .cgi .fcgi
        Order allow,deny
        Allow from all
        AllowOverride AuthConfig
        AuthName "Smokeping"
        AuthType Basic
        AuthUserFile /usr/local/smokeping/htdocs/htpasswd
        Require valid-user
        DirectoryIndex smokeping.fcgi
</Directory>' >/etc/httpd/conf.d/smokeping.conf

htpasswd -c /usr/local/smokeping/htdocs/htpasswd ca0gu0

 

#/usr/local/smokeping/bin/smokeping --config=/usr/local/smokeping/etc/config --debug

ntpdate time.windows.com
echo "user:passwd" >/usr/local/smokeping/etc/smokeping_secrets.dist
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
chown apache. /usr/local/smokeping/etc/smokeping_secrets.dist

 

vi /etc/init.d/smokeping
#!/bin/bash
#
# chkconfig: 2345 80 05
# Description: Smokeping init.d script
# Hacked by : How2CentOS - http://www.how2centos.com
# Get function from functions library
. /etc/init.d/functions
# Start the service Smokeping
start() {
        echo -n "Starting Smokeping: "
        /usr/local/smokeping/bin/smokeping --config=/usr/local/smokeping/etc/config --logfile=/var/log/smokeping.log --debug-daemon >/dev/null 2>&1
        RETVAL=$?
        [ $RETVAL == 0 ] && success $"Smokeping startup"
        [ $RETVAL == 0 ] && touch /var/lock/subsys/smokeping
        echo
        return $RETVAL

}
# Restart the service Smokeping
stop() {
        echo -n "Stopping Smokeping: "
        kill -9 `ps ax | grep "/usr/local/smokeping/bin/smokeping" | grep -v grep | awk "{ print $1 }"`>/dev/null 2>&1
        success $"Smokeping shutdown"
        rm -f /var/lock/subsys/smokeping
        echo
}
### main logic ###
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        if [ -f /var/lock/subsys/smokeping ]; then
          echo "Smokeping is runing"
          exit 0
        fi
        echo "Smokeping is stopped"
        exit 3

        ;;
  restart|reload|condrestart)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac
exit 0

 

chown -R apache.apache /usr/local/smokeping/cache /usr/local/smokeping/data /usr/local/smokeping/var

 

 

 

 

四.监测节点配置

#64bit
rpm -Uhv http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

#32bit
#rpm -Uhv http://apt.sw.be/redhat/el6/en/i386/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.i686.rpm

#install
yum -y install rrdtool fping echoping curl bind-utils 
yum -y install httpd 
yum -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 gcc wget perl-CPAN perl-devel perl-FCGI perl-CGI rrdtool-perl

wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz
tar zxvf smokeping-2.6.9.tar.gz
cd smokeping-2.6.9

./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
./configure --prefix=/usr/local/smokeping
/usr/bin/gmake install


mkdir -p /usr/local/smokeping/cache

chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
echo "passwd" >/usr/local/smokeping/etc/smokeping_secrets.dist

 

vi /etc/init.d/smokeping
#!/bin/bash
#
# chkconfig: 2345 80 05
# Description: Smokeping init.d script
# Hacked by : How2CentOS - http://www.how2centos.com
# Get function from functions library
. /etc/init.d/functions
# Start the service Smokeping
start() {
        echo -n "Starting Smokeping: "
        /usr/local/smokeping/bin/smokeping --master=http://ca0gu0:ca0gu0pass@192.168.66.32:80/smokeping/smokeping.fcgi \
                                           --cache-dir=/usr/local/smokeping/cache \
                                           --shared-secret=/usr/local/smokeping/etc/smokeping_secrets.dist \
                                           --slave-name=user \
                                           --logfile=/var/log/smokeping.log \
                                           --debug-daemon >/dev/null 2>&1
        ### Create the lock file ###
        success $"Smokeping startup"
        touch /var/lock/subsys/smokeping
        echo
}
# Restart the service Smokeping
stop() {
        echo -n "Stopping Smokeping: "
        kill -9 `ps ax | grep "/usr/local/smokeping/bin/smokeping" | grep -v grep | awk "{print $1}"` >/dev/null 2>&1
        ### Now, delete the lock file ###
        rm -f /var/lock/subsys/smokeping
        success $"Smokeping shutdown"
        echo
}
### main logic ###
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        if [ -f /var/lock/subsys/smokeping ]; then
          echo "Smokeping is runing"
          exit 0
        fi
        echo "Smokeping is stopped"
        exit 3
        ;;
  restart|reload|condrestart)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac
exit 0

 

 

posted @ 2015-11-17 23:31  ca0guo  阅读(942)  评论(0编辑  收藏  举报