阿里狼 发表于 2019-1-17 11:46:28

smokeping的搭建

推荐各种安装包网站:http://apache.freelamp.com
                      http://dag.wieers.com/rpm/packages
                      http://oss.oetiker.ch/

一、所需安装包
apr-1.4.2.tar.bz2
apr-util-1.3.10.tar.gz
echoping-5.2.0-1.2.el4.rf.i386.rpm
fping-2.4-1.b2.2.el5.rf.i386.rpm
httpd-2.2.17.tar.bz2
perl-CGI-SpeedyCGI-2.22-4.el5.i386.rpm
rrdtool-1.4.3.tar.gz
smokeping-2.4.2.tar.gz
二、    安装配置(需要以下包):
yum -y install freetype freetype-devel libpng libpng-devel gd gd-devel libxml2 libxml2-devel libiconv
libiconv-devel pango pango-devel qpixman qpixman-devel glib glib-devel cairo cairo-devel libart* gettext
gettext-devel libjpeg libjpeg-devel perl-XML-Simple.noarch perl-Crypt-SSLeay perl-Digest-HMAC

rpm –ivh echoping-5.2.0-1.2.el4.rf.i386.rpm
rpm –ivh fping-2.4-1.b2.2.el5.rf.i386.rpm
rpm –ivh perl-CGI-SpeedyCGI-2.22-4.el5.i386.rpm

useradd -s /sbin/nologon apache
安装软件包
tar xf apr-1.4.2.tar.bz2
cd apr-1.4.2
./configure --prefix=/usr/local/apr
make
make install

tar xf apr-util-1.3.10.tar.gz
cd apr-util-1.3.10
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
tar xf httpd-2.2.17.tar.bz2
cd httpd-2.2.17
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make
make install

tar xf rrdtool-1.4.3.tar.gz
cd rrdtool-1.4.3
sed -i 's/setlocale(LC_NUMERIC, "C")/setlocale(LC_NUMERIC, "zh_CN.UTF-8")/g' src/rrd_graph.c                                             
./configure --prefix=/usr/local/rrdtool
make
make install

tar xf smokeping-2.4.2.tar.gz
mv smokeping-2.4.2 /usr/local/smokeping
mkdir /usr/local/smokeping/{cache,var}
sed -i 's/^User daemon/User apache/1;s/^Group daemon/Group apache/1' /usr/local/apache/conf/httpd.conf

将下列内容添加到/usr/local/apache/conf/httpd.conf中,使smokeping与apache相关联。
Alias /smokeping/ "/usr/local/smokeping/"

      AllowOverride None
       AddHandler cgi-script cgi
      Options ExecCGI
      Order allow,deny
      Allow from all
      DirectoryIndex smokeping.cgi


将/etc/init.d/httpd换成新编译好的配置/usr/local/apache/bin/apachectl,改名为httpd

rm -f /etc/init.d/httpd
/bin/cp -rp /usr/local/apache/bin/apachectl/etc/init.d/httpd

将/etc/init.d/httpd内容中第二行开始插入以下内容:
sed -i '2a #chkconfig: 2345 10 90\n#description: Activates/Deactivates Apache Web Server'/etc/init.d/httpd

修改权限
chmod 755 /etc/init.d/httpd
chkconfig --add httpd
chkconfig --level 3 httpd on
/etc/init.d/httpd start

chmod u+s /bin/traceroute

vi /etc/init.d/smokeping
chmod 755 /etc/init.d/smokeping
chown -R apache:apache /usr/local/smokeping
chmod -R +x /usr/local/smokeping/bin
chmod -R +x /usr/local/smokeping/htdocs

三、安装完成
访问地址:http://ip/smokeping/htdocs/smokeping.cgi

重启smokeping:/etc/init.d/smokeping restart

配置文件的修改:
1、 修改/usr/local/smokeping/etc/config.dist

*** General ***

owner    = apache
contact = kylin@7oyx.com
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 images.
imgcache = /usr/local/smokeping/cache
imgurl   = ../cache
datadir = /usr/local/smokeping/var
piddir = /usr/local/smokeping/var
cgiurl   = http://ip/smokeping/htdocs/smokeping.cgi
smokemail = /usr/local/smokeping/etc/smokemail.dist

tmail = /usr/local/smokeping/etc/tmail.dist


*** Probes ***

+ FPing

binary = /usr/sbin/fping


以下添加相关监控内容(如要显示中文在title后面敲入中文即可):

+ WT

menu= WT
title = WT
alerts = someloss

++ WangTong-1

menu = WangTong-1
title = 网通-1_192.168.0.11
host = 192.168.0.11
...
.....

1、 etc/init.d/下编辑一个smokeping的文件

#!/bin/sh
#
# Description: start/stop script for smokeping
# Autor: Michel Tokic
#

# the path to your PID file
PIDFILE=/usr/local/smokeping/var/smokeping.pid
# path to smokeping script
SMOKEPING=/usr/local/smokeping/bin/smokeping.dist


ERROR=0
RUNNING=0
ARGV="$@"
if [ "x$ARGV" = "x" ] ; then
    ARGS=help
fi

for ARG in $@ $ARGS
do

    if [ -f $PIDFILE ] ; then
      PID=`cat $PIDFILE`
      if kill -0 $PID 2>/dev/null ; then
            # smokeping is running
            RUNNING=1
      else
            # smokeping not running but PID file exists => delete PID file
            rm -f $PIDFILE
            RUNNING=0
      fi
    else
      # smokeping (no pid file) not running
      RUNNING=0
    fi

    case $ARG in
    start)

      if [ $RUNNING -eq 0 ] ; then
            if $SMOKEPING > /dev/null; then
                echo "$0 $ARG: smokeping started"
            else
                echo "$0 $ARG: smokeping could not be started"
                ERROR=1
            fi
      else
            echo "$0 $ARG: smokeping is running with PID $PID"
            ERROR=2
      fi
      ;;
    stop)
      if [ $RUNNING -eq 1 ] ; then
            if kill $PID ; then
                echo "$0 $ARG: smokeping ($PID) stopped"
                rm $PIDFILE
            else
            fi
      else
            echo "$0 $ARG: smokeping not running"
            ERROR=4
      fi
      ;;
            if $SMOKEPING --restart > /dev/null; then
                echo "$0 $ARG: smokeping restarted"
            else
                echo "$0 $ARG: smokeping could not be started"
                ERROR=5
            fi
      else
             $0 start
      fi
      ;;
    strace_debug)
      rm -f /tmp/strace_smokeping
      if [ $RUNNING -eq 1 ] ; then
            if strace -o/tmp/strace_smokeping $SMOKEPING --restart >/dev/null; then
            else
                echo "$0 $ARG: smokeping strace debug could not be started"
                ERROR=6
            fi
      else
            if strace -o/tmp/strace_smokeping $SMOKEPING >/dev/null; then
            else
                echo "$0 $ARG: smokeping strace debug could not be started"
                ERROR=7
            fi
      fi
      ;;
    status)
      if [ $RUNNING -eq 1 ] ; then
            echo "$0 $ARG: smokeping is running with PID ($PID)"
      else
            echo "$0 $ARG: smokeping is not running"
      fi
      ;;
    *)
      echo "usage: $0 (start|stop|restart|status|strace_debug|help)"
      cat
页: [1]
查看完整版本: smokeping的搭建