Smokeping初始配置

修改smokeping相關文件名

在smokeping的子目錄中會發現很多“*.dist”命名的文件,這些文件使用的時候請將其改名爲“*”並進行配置,可以通過如下命令批量操作:

ls | while read name; do mv ${name} ${name%%.*};done;


建立相關目錄

接着建立三個目錄用於保存smokeping的數據等,如下所示:

mkdir /usr/local/smokeping/data

mkdir /usr/local/smokeping/var

mkdir /usr/local/smokeping/cache

chown –R apache.apache /usr/local/smokeping


修改配置文件

(1)/usr/local/smokeping/etc/config (somkeping配置基本都在這個文件上)

*** General ***

owner =

contact =

mailhost = my.mail.host

sendmail = /usr/lib/sendmail

imgcache = /usr/local/smokeping/htdocs/cache

imgurl = cache

datadir = /data/smokeping/data

piddir = /usr/local/smokeping/var

cgiurl = http://IP/smokeping/smokeping.cgi

smokemail = /usr/local/smokeping/etc/smokemail

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

*** Presentation ***

template = /usr/local/smokeping/etc/basepage.html

charset = UTF-8


(2)把#*** Slaves ***下的所有東西註釋掉,這裏暫時不採用master/slave模式。

(3)在Targets下添加監控節點,其中Multi也就是在一張圖裏畫多個監測點的數值:

+ Telecom

menu= TeleCom

title = 21ViaNet(China)Telecom

++ HeiLJ

menu = HeiLJ

title = HeiLJ_219.147.130.76

host = 219.147.130.76

++ JiLin menu = JiLin

title = JiLin_219.149.194.1

host = 219.149.194.1

++ TeleComMulti

menu = TeleMulti

title = 21ViaNet(China) Telecom Network

host = /Telecom/HeiLJ /Telecom/JiLin


(4) /usr/local/smokeping/htdocs/smokeping.cgi 注意修改如下內容即可

#!/usr/bin/speedy –w use lib qw(/usr/local/rrdtool/lib/perl);

use lib qw(/usr/local/smokeping/lib); Smokeping::cgi("/usr/local/smokeping/etc/config ");


(5)/usr/local/smokeping/bin/smokeping 注意修改如下內容即可:

#!/usr/bin/perl –w

use lib qw(/usr/local/rrdtool/lib/perl);

use lib qw(/usr/local/smokeping/lib); Smokeping::main("/usr/local/smokeping/etc/config");


啓動smokeping

(1)編寫smokeping啓動腳本,賦予可執行權限,並放在/etc/init.d目錄下

#!/bin/sh

PIDFILE=/usr/local/smokeping/var/smokeping.pid

SMOKEPING=/usr/local/smokeping/bin/smokeping

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

echo "$0 $ARG: smokeping could not be stopped"

ERROR=3

fi

else

echo "$0 $ARG: smokeping not running"

ERROR=4

fi

;;

restart)

if [ $RUNNING -eq 1 ] ; then

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

echo "$0 $ARG: smokeping restarted with strace debug in /tmp/strace_smokeping"

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

echo "$0 $ARG: smokeping started with strace debug in /tmp/strace_smokeping"

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 <&lt;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


(2)檢查smokeping配置文件: /usr/local/smokeping/bin/smokeping --check

啓動smokeping:service smokeping start

(3)配置apache/conf/httpd.conf

Alias /smokeping/ "/usr/local/smokeping/htdocs/"

Alias /cache/ "/usr/local/smokeping/cache/"

&lt;Directory "/usr/local/smokeping/htdocs">

Options FollowSymLinks ExecCGI

AllowOverride None

AddHandler cgi-script cgi

Order allow,deny

Allow from all

</Directory>


(4)修改完後重啓apache,在瀏覽器輸入 http://IP/smokeping/smokeping.cgi


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章