smokeping的搭建

 

推薦各類安裝包網站: http://apache.freelamp.com
                      http://dag.wieers.com/rpm/packages
                      http://oss.oetiker.ch/
 
1、所需安裝包
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
2、     安裝配置 (須要如下包):
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/"
<Directory /usr/local/smokeping/>
        AllowOverride None
        AddHandler cgi-script cgi
        Options ExecCGI
        Order allow,deny
        Allow from all
        DirectoryIndex smokeping.cgi
</Directory>
 
/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
 
3、安裝完成
 
重啓 smokeping:/etc/init.d/smokeping restart
 
配置文件的修改:
一、 修改 /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 p_w_picpaths.
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
...
.....
 
一、  etc/init.d/下編輯一個smokeping的文件
 
#!/bin/sh
#
# Description: start/stop script for smokeping
# Autor: Michel Tokic <michel@tokic.com>
#
 
# 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 <<EOF
 
 start       - start smokeping
 stop        - stop smokeping
 restart     - restart smokeping if running or start if not running
 status      - show status if smokeping is running or not
 help        - this screen
 
EOF
 
         ;;
 
    esac
done
exit $ERROR
 
 
三、/usr/local/smokeping/htdocs/smokeping.cgi
 
#!/usr/bin/speedy
# -*-perl-*-
 
use strict;
use warnings;
 
use lib qw(/usr/local/rrdtool/lib/perl);
use lib qw(/usr/local/smokeping/lib);
 
use CGI::Carp qw(fatalsToBrowser);
 
use Smokeping 2.004002;
 
Smokeping::cgi("/usr/local/smokeping/etc/config.dist");
 
四、 /usr/local/smokeping/bin/smokeping.dist
 
#!/usr/bin/perl -w
# -*-perl-*-
 
use lib qw(/usr/local/rrdtool/lib/perl);
use lib qw(/usr/local/smokeping/lib);
use strict;
use warnings;
use Smokeping 2.004002;
 
Smokeping::main("/usr/local/smokeping/etc/config.dist");
 
 
 
 
 
五、 /usr/local/smokeping/htdocs/tr.cgi
 
#!/usr/bin/speedy -w
use strict;
use lib qw(/usr/local/rrd/lib/perl);
use lib qw(/usr/local/smokeping/lib);
 
4、中文顯示
rrdtool 讓圖片顯示中文
rrdtools 須要1.4 以上的版本;
安裝以下:
tar xf rrdtools.1.4.x.x && cd rrdtools.1.4.x
sed -i 's/setlocale(LC_NUMERIC, "C")/setlocale(LC_NUMERIC, "zh_CN.UTF-8")/g' src/rrd_graph.c
./configure --prefix=/usr/local/rrdtools && make && make install
 
 
相關文章
相關標籤/搜索