diff options
author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2002-01-22 13:30:01 +0000 |
---|---|---|
committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2002-01-22 13:30:01 +0000 |
commit | e006ac7eca2cebd54065da4fc5c6e099205bb107 (patch) | |
tree | f125500f39819f8f18b516e8d60be2a7a37d32f9 /misc/init.d/redhat | |
parent | fd674a4d69121377c82784e98356f42d51c8deb6 (diff) | |
download | zabbix-e006ac7eca2cebd54065da4fc5c6e099205bb107.tar.gz zabbix-e006ac7eca2cebd54065da4fc5c6e099205bb107.tar.xz zabbix-e006ac7eca2cebd54065da4fc5c6e099205bb107.zip |
Added startup scripts for RedHat. Thanks to Charlie Collins.
git-svn-id: svn://svn.zabbix.com/trunk@297 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'misc/init.d/redhat')
-rwxr-xr-x | misc/init.d/redhat/zabbix_agentd_ctl | 150 | ||||
-rwxr-xr-x | misc/init.d/redhat/zabbix_suckerd_ctl | 150 |
2 files changed, 300 insertions, 0 deletions
diff --git a/misc/init.d/redhat/zabbix_agentd_ctl b/misc/init.d/redhat/zabbix_agentd_ctl new file mode 100755 index 00000000..ca74a785 --- /dev/null +++ b/misc/init.d/redhat/zabbix_agentd_ctl @@ -0,0 +1,150 @@ +#!/bin/sh +# +# zabbix_agentd_ctl +# +# control script to stop/start/restart zabbix_suckerd +# author: charlie collins +# date: 01.21.2002 +# +# (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 (PID FILE NOT CURRENTLY SET - NEEDS TO BE, THIS IS FOR FUTURE USE) +PIDFILE=$BASEDIR/bin/zabbix_agentd.pid +# binary file +ZABBIX_AGENTD=$BASEDIR/bin/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 + +# establish PIDs +# for now - ultimately PIDFILE should be implemented and managed in zabbix_agentd binary +# output all process ids to PIDFILE manually +ps -ef | awk '/zabbix_agentd/ && !/zabbix_agentd_ctl/ && !/awk/ {print $2}' > $PIDFILE + + +# 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 <<EOF + +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 + + + diff --git a/misc/init.d/redhat/zabbix_suckerd_ctl b/misc/init.d/redhat/zabbix_suckerd_ctl new file mode 100755 index 00000000..196c64c9 --- /dev/null +++ b/misc/init.d/redhat/zabbix_suckerd_ctl @@ -0,0 +1,150 @@ +#!/bin/sh +# +# zabbix_suckerd_ctl +# +# control script to stop/start/restart zabbix_suckerd +# author: charlie collins +# date: 01.21.2002 +# +# (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_suckerd could not be started +# 4 - zabbix_suckerd could not be stopped +# 5 - zabbix_suckerd could not be started during a restart +# 6 - zabbix_suckerd 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 (PID FILE NOT CURRENTLY SET - NEEDS TO BE, THIS IS FOR FUTURE USE) +PIDFILE=$BASEDIR/bin/zabbix_suckerd.pid +# binary file +ZABBIX_SUCKERD=$BASEDIR/bin/zabbix_suckerd + + +# ************** +# logic section (below here) does NOT normally need any modification +# ************** + +# establish args +ERROR=0 +ARGV="$@" +if [ "x$ARGV" = "x" ] ; then + ARGS="help" +fi + +# establish PIDs +# for now - ultimately PIDFILE should be implemented and managed in zabbix_suckerd binary +# output all process ids to PIDFILE manually +ps -ef | awk '/zabbix_suckerd/ && !/zabbix_suckerd_ctl/ && !/awk/ {print $2}' > $PIDFILE + + +# 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_suckerd (pid $PID) running" + RUNNING=1 + else + STATUS="zabbix_suckerd (pid $PID?) not running" + RUNNING=0 + fi + else + STATUS="zabbix_suckerd (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_suckerd (pid $PID) already running" + continue + fi + if $ZABBIX_SUCKERD ; then + echo "$0 $ARG: zabbix_suckerd started" + else + echo "$0 $ARG: zabbix_suckerd 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_suckerd process(es) stopped" + else + echo "$0 $ARG: zabbix_suckerd process(es) could not be stopped" + ERROR=4 + fi + ;; + + restart) + if [ $RUNNING -eq 0 ]; then + echo "$0 $ARG: zabbix_suckerd not running, trying to start" + if $ZABBIX_SUCKERD ; then + echo "$0 $ARG: zabbix_suckerd started" + else + echo "$0 $ARG: zabbix_suckerd could not be started" + ERROR=5 + fi + else + if kill $PID ; then + if $ZABBIX_SUCKERD ; then + echo "$0 $ARG: zabbix_suckerd restarted" + else + echo "$0 $ARG: zabbix_suckerd could not be started" + ERROR=3 + fi + else + echo "$0 $ARG: zabbix_suckerd could not be restarted" + ERROR=6 + fi + fi + ;; + + *) + + echo "usage: $0 (start|stop|restart|help)" + cat <<EOF + +start - start zabbix_suckerd +stop - stop zabbix_suckerd +restart - restart zabbix_suckerd if running by sending a SIGHUP or start if not running +help - this screen + +EOF + + ERROR=2 + ;; + + esac + +done + +exit $ERROR + + + |