zabbix_proxy开机启动脚本

zabbix init开机脚本——redhat6系统(centos6通用)
将下面代码存在/etc/init.d/zabbix-proxy
chkconfig zabbix-proxy on

. /etc/init.d/functions
    BASEDIR=/usr/local/sbin
        BINARY_NAME=zabbix_agent
        FULLPATH=$BASEDIR/sbin/$BINARY_NAME
        PIDFILE=/tmp/$BINARY_NAME.pid
        ERROR=0
    STOPPING=0

if [ -f $PIDFILE  ] && [ -s $PIDFILE ]
    then
    PID=`cat $PIDFILE`

    if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null && [ $BINARY_NAME == `ps -e | grep $PID | awk '{print $4}'` ]
    then
        STATUS="$BINARY_NAME (pid `pidof $APP`) running.."
        RUNNING=1
    else
        rm -f $PIDFILE
        STATUS="$BINARY_NAME (pid file existed ($PID) and Now removed) not running.."
        RUNNING=0
    fi
else
    if [ `ps -e | grep $BINARY_NAME | head -1 | awk '{ print $1 }'` ]
        then
        STATUS="$BINARY_NAME (pid `pidof $APP`, but no pid file) running.."
    else
        STATUS="$BINARY_NAME (no pid file) not running"
    fi
    RUNNING=0
fi

start() {
    if [ $RUNNING -eq 1 ]
        then
        echo "$0 $ARG: $BINARY_NAME (pid $PID) already running"
    else
        action $"Starting $BINARY_NAME: " $FULLPATH
        touch /var/lock/subsys/$BINARY_NAME
    fi
}

stop() {
    echo -n $"Shutting down $BINARY_NAME: "
    killproc $BINARY_NAME
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BINARY_NAME
    RUNNING=0
}
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status $BINARY_NAME
        ;;
    restart)
        stop
        sleep 10
        start
        ;;
    help|*)
        echo $"Usage: $0 {start|stop|status|restart|help}"
        cat <<EOF

            start       - start $BINARY_NAME
            stop        - stop $BINARY_NAME
            status      - show current status of $BINARY_NAME
            restart     - restart $BINARY_NAME if running by sending a SIGHUP or start if not running
            help        - this screen

EOF
    exit 1
    ;;
esac

exit 0

zabbix init开机脚本——Ubuntu系统
将下面代码存在/etc/init.d/zabbix-proxy
update-rc.d zabbix-proxy defaults 95

NAME=zabbix_proxy
DAEMON=/usr/local/sbin/${NAME}
DESC="Zabbix proxy daemon"
PID=/tmp/$NAME.pid

test -f $DAEMON || exit 0

case "$1" in
  start)
        echo "Starting $DESC: $NAME"
        start-stop-daemon --start --oknodo --pidfile $PID --exec $DAEMON
        ;;
  stop)
        echo "Stopping $DESC: $NAME"
        start-stop-daemon --stop --quiet --pidfile $PID --retry=TERM/10/KILL/5 && exit 0
        start-stop-daemon --stop --oknodo --exec $DAEMON --name $NAME --retry=TERM/10/KILL/5
        ;;
  restart|force-reload)
        $0 stop
        $0 start
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

相关文章

今天小编给大家分享一下excel图案样式如何设置的相关知识点,...
这篇文章主要讲解了“win10设置过的壁纸如何删除”,文中的讲...
这篇“Xmanager怎么显示远程linux程序的图像”文章的知识点大...
今天小编给大家分享一下xmanager怎么连接linux的相关知识点,...
这篇“如何重置Linux云服务器的远程密码”文章的知识点大部分...
本篇内容介绍了“Linux云服务器手动配置DNS的方法是什么”的...