diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-05-28 13:32:10 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-05-28 13:32:10 +0000 |
| commit | 3442ec61fa38eea4e68a3edea4ea3225ff78c8a0 (patch) | |
| tree | 3ebf399a0be7c8ca22745e08ae2c0b4e300a86e5 /misc/init.d/redhat/zabbix_server_ctl | |
| parent | fb8127285b3156270151079a29825130cf85d524 (diff) | |
| download | zabbix-3442ec61fa38eea4e68a3edea4ea3225ff78c8a0.tar.gz zabbix-3442ec61fa38eea4e68a3edea4ea3225ff78c8a0.tar.xz zabbix-3442ec61fa38eea4e68a3edea4ea3225ff78c8a0.zip | |
- modifed startup scripts (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@4187 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'misc/init.d/redhat/zabbix_server_ctl')
| -rwxr-xr-x | misc/init.d/redhat/zabbix_server_ctl | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/misc/init.d/redhat/zabbix_server_ctl b/misc/init.d/redhat/zabbix_server_ctl new file mode 100755 index 00000000..52a2a685 --- /dev/null +++ b/misc/init.d/redhat/zabbix_server_ctl @@ -0,0 +1,149 @@ +#!/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/bin/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 <<EOF + +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 + + + |
