日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux做成service服务器,Zabbix2.0.3做成Service

發(fā)布時間:2025/4/16 linux 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux做成service服务器,Zabbix2.0.3做成Service 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

zabbix2.0.3沒有現(xiàn)成的CentOS可用的service腳本,但是2.0.0有,下載2.0.0的腳本。

在源碼包的zabbix-1.8.15\misc\init.d 路徑下的RedHat里。

復(fù)制到/etc/init.d目錄下。

修改腳本里的變量:BASEDIR和PIDFILE 的值。可以在zabbix/etc/zabbix_agentd.conf和zabbix_server.conf里找到

腳本內(nèi)容如下

zabbix_server:

#!/bin/sh

#

# zabbix_server_ctl

#

# control script to stop/start/restart zabbix_server

# author: charlie collins

# date: 01.21.2002

#

# revised 09.21.2003

# (setup for Red Hat 7.3 with Zabbix 1.0 beta)

# (should work for other Red Hat and Sys V style init machines as well)

#

# (modeled after apache style control scripts)

# (this script can be placed in init.d and respective runlevel for startup usage)

#

#

# The exit codes returned are:

#? 0 - operation completed successfully

#? 1 -

#? 2 - usage error

#? 3 - zabbix_server could not be started

#? 4 - zabbix_server could not be stopped

#? 5 - zabbix_server could not be started during a restart

#? 6 - zabbix_server could not be restarted during a restart

#

#

#

# **************

# config options

# **************

#

# (set config options to match your system settings)

# base zabbix dir

BASEDIR=/opt/zabbix

# PID file

PIDFILE=/var/tmp/zabbix_server.pid

# binary file

ZABBIX_SUCKERD=$BASEDIR/sbin/zabbix_server

# **************

# logic section (below here) does NOT normally need any modification

# **************

# establish args

ERROR=0

ARGV="$@"

if [ "x$ARGV" = "x" ] ; then

ARGS="help"

fi

# perform action based on args

for ARG in $@ $ARGS

do

# check if PIDFILE exists and ensure is not zero size and react accordingly

if [ -f $PIDFILE? ] && [ -s $PIDFILE ] ; then

PID=`cat $PIDFILE`

if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then

STATUS="zabbix_server (pid $PID) running"

RUNNING=1

else

STATUS="zabbix_server (pid $PID?) not running"

RUNNING=0

fi

else

STATUS="zabbix_server (no pid file) not running"

RUNNING=0

fi

# parse arg and react accordingly

case $ARG in

start)

if [ $RUNNING -eq 1 ]; then

echo "$0 $ARG: zabbix_server (pid $PID) already running"

continue

fi

if $ZABBIX_SUCKERD ; then

echo "$0 $ARG: zabbix_server started"

else

echo "$0 $ARG: zabbix_server could not be started"

ERROR=3

fi

;;

stop)

if [ $RUNNING -eq 0 ]; then

echo "stop called - in running eq 0"

echo "$0 $ARG: $STATUS"

continue

fi

if kill $PID ; then

echo "$0 $ARG: zabbix_server process(es) stopped"

else

echo "$0 $ARG: zabbix_server process(es) could not be stopped"

ERROR=4

fi

;;

restart)

if [ $RUNNING -eq 0 ]; then

echo "$0 $ARG: zabbix_server not running, trying to start"

if $ZABBIX_SUCKERD ; then

echo "$0 $ARG: zabbix_server started"

else

echo "$0 $ARG: zabbix_server could not be started"

ERROR=5

fi

else

if kill $PID ; then

if $ZABBIX_SUCKERD ; then

echo "$0 $ARG: zabbix_server restarted"

else

echo "$0 $ARG: zabbix_server could not be started"

ERROR=3

fi

else

echo "$0 $ARG: zabbix_server could not be restarted"

ERROR=6

fi

fi

;;

*)

echo "usage: $0 (start|stop|restart|help)"

cat <

start? ? ? - start zabbix_server

stop? ? ? - stop zabbix_server

restart? ? - restart zabbix_server if running by sending a SIGHUP or start if not running

help? ? ? - this screen

EOF

ERROR=2

;;

esac

done

exit $ERROR

#############################################################################################

zabbix_agentd:

#!/bin/sh

#

# zabbix_agentd_ctl

#

# control script to stop/start/restart zabbix_agentd

# author: charlie collins

# date: 01.21.2002

#

# revised 09.21.2003

# (setup for Red Hat 7.3 with Zabbix 1.0 beta)

# (should work for other Red Hat and Sys V style init machines as well)

#

# (modeled after apache style control scripts)

# (this script can be placed in init.d and respective runlevel for startup usage)

#

#

# The exit codes returned are:

#? 0 - operation completed successfully

#? 1 -

#? 2 - usage error

#? 3 - zabbix_agentd could not be started

#? 4 - zabbix_agentd could not be stopped

#? 5 - zabbix_agentd could not be started during a restart

#? 6 - zabbix_agentd could not be restarted during a restart

#

#

#

# **************

# config options

# **************

#

# (set config options to match your system settings)

# base zabbix dir

BASEDIR=/opt/zabbix

# pid file (as of 1.0 beta 10)

PIDFILE=/var/tmp/zabbix_agentd.pid

# binary file

ZABBIX_AGENTD=$BASEDIR/sbin/zabbix_agentd

# **************

# logic section (below here) does NOT normally need any modification

# **************

# establish args

ERROR=0

ARGV="$@"

if [ "x$ARGV" = "x" ] ; then

ARGS="help"

fi

# perform action based on args

for ARG in $@ $ARGS

do

# check if PIDFILE exists and ensure is not zero size and react accordingly

if [ -f $PIDFILE? ] && [ -s $PIDFILE ] ; then

PID=`cat $PIDFILE`

if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then

STATUS="zabbix_agentd (pid $PID) running"

RUNNING=1

else

STATUS="zabbix_agentd (pid $PID?) not running"

RUNNING=0

fi

else

STATUS="zabbix_agentd (no pid file) not running"

RUNNING=0

fi

# parse arg and react accordingly

case $ARG in

start)

if [ $RUNNING -eq 1 ]; then

echo "$0 $ARG: zabbix_agentd (pid $PID) already running"

continue

fi

if $ZABBIX_AGENTD ; then

echo "$0 $ARG: zabbix_agentd started"

else

echo "$0 $ARG: zabbix_agentd could not be started"

ERROR=3

fi

;;

stop)

if [ $RUNNING -eq 0 ]; then

echo "stop called - in running eq 0"

echo "$0 $ARG: $STATUS"

continue

fi

if kill $PID ; then

echo "$0 $ARG: zabbix_agentd process(es) stopped"

else

echo "$0 $ARG: zabbix_agentd process(es) could not be stopped"

ERROR=4

fi

;;

restart)

if [ $RUNNING -eq 0 ]; then

echo "$0 $ARG: zabbix_agentd not running, trying to start"

if $ZABBIX_AGENTD ; then

echo "$0 $ARG: zabbix_agentd started"

else

echo "$0 $ARG: zabbix_agentd could not be started"

ERROR=5

fi

else

if kill $PID ; then

if $ZABBIX_AGENTD ; then

echo "$0 $ARG: zabbix_agentd restarted"

else

echo "$0 $ARG: zabbix_agentd could not be started"

ERROR=3

fi

else

echo "$0 $ARG: zabbix_agentd could not be restarted"

ERROR=6

fi

fi

;;

*)

echo "usage: $0 (start|stop|restart|help)"

cat <

start? ? ? - start zabbix_agentd

stop? ? ? - stop zabbix_agentd

restart? ? - restart zabbix_agentd if running by sending a SIGHUP or start if not running

help? ? ? - this screen

EOF

ERROR=2

;;

esac

done

exit $ERROR

總結(jié)

以上是生活随笔為你收集整理的linux做成service服务器,Zabbix2.0.3做成Service的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。