设置smokeping开机启动

1、设置smokeping启动脚本

root@linux-node2 ~]# cat /etc/init.d/smokeping                 #smokeping启动脚本

#!/bin/bash

#

# chkconfig: 2345 80 05

# Description: Smokeping init.d script

# Write by : linux-Leon_xiedi

# Get function from functions library

. /etc/init.d/functions

# Start the service Smokeping

function start() {

                echo -n "Starting Smokeping: "

                /usr/local/smokeping/bin/smokeping >/dev/null 2>&1

                ### Create the lock file ###

                touch /var/lock/subsys/smokeping

                success $"Smokeping startup"

                echo

}

# Restart the service Smokeping

function 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

}

#Show status about Smokeping

function status() {

                NUM="`ps -ef|grep smokeping|grep -v grep|wc -l`"

                if [ "$NUM" == "0" ];then

                   echo "Smokeping is not run"

                else

                   echo "Smokeping is running"

                fi



}

### main logic ###

case "$1" in

start)

        start

        ;;

stop)

        stop

        ;;

status)

        status

        ;;

restart|reload)

        stop

        start

;;

*)

echo $"Usage: $0 {start|stop|restart|reload|status}"

exit 1

esac

exit 0

2、启动服务以及访问smokeping

[root@linux]# chmod 755 /etc/init.d/smokeping #添加脚本755权限

[root@linux]# chkconfig –add smokeping #将smokeping加入开机启动

[root@linux]# chkconfig smokeping on #设置smokeping为开机启动

[root@linux]# chkconfig httpd on #设置apache为开机启动

[root@linux]# service httpd restart #重启apache服务

[root@linux]#service smokeping restart #重启smokeping服务

你可能感兴趣的:(smokeping,开机启动)