File pnp4nagios-pnp_gearman_worker-init of Package pnp4nagios

#! /bin/sh
# Copyright (c) 2007 SuSE Linux AG Nuernberg, Germany.
#
# Author: Lars Vogdt 
#
# /etc/init.d/pnp_gearman_worker
#
#   and symbolic its link
#
# /usr/sbin/rcpnp_gearman_worker
#
# System startup script for ncpd
#
### BEGIN INIT INFO
# Provides:       pnp_gearman_worker
# Required-Start: $local_fs $remote_fs gearmand
# Required-Stop:  $local_fs $remote_fs gearmand
# Should-Start:   monitoring_daemon
# Should-Stop:    monitoring_daemon
# Default-Start:  3 5
# Default-Stop:   0 1 2 6
# Short-Description: PNP4Nagios Gearman Mode
# Description:    Adds a queue to a running gearman daemon
#   that will process performance data from a monitoring
#   daemon like Icinga or Nagios.
### END INIT INFO

. /etc/rc.status

PERFDATA_BIN=NAGIOS_PLUGINDIR/process_perfdata.pl
PERFDATA_CFG=PNP4NAGIOS_SYSCONFDIR/process_perfdata.cfg
SYSCONFIG=/etc/sysconfig/pnp4nagios
NAME=pnp_gearman_worker
PID=/var/run/${NAME}/${NAME}.pid

# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
test -x $PERFDATA_BIN || { echo "$PERFDATA_BIN not installed";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 3; fi; }

# Check for existence of needed config file and read it
test -r $PERFDATA_CFG || { echo "$PERFDATA_CFG not existing";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 3; fi; }

# Check for existence of needed config file and read it
test -r $SYSCONFIG || { echo "$SYSCONFIG not existing";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 3; fi; }

. "$SYSCONFIG"

CMD="$PERFDATA_BIN --pidfile=$PID --config=$PERFDATA_CFG --gearman --daemon"

# Reset status of this service
rc_reset

case "$1" in
    start)
        echo -n "Starting $NAME "
        mkdir -p $(dirname $PID)
        chown $PNP_GEARMAN_WORKER_USER: $(dirname $PID)
        startproc -u $PNP_GEARMAN_WORKER_USER $CMD
        rc_status -v
    ;;
    stop)
        echo -n "Shutting down $NAME " 
        killproc -p $PID $PERFDATA_BIN -TERM
        rc_status -v
    ;;
    try-restart|condrestart)
        ## Do a restart only if the service was active before.
        ## Note: try-restart is now part of LSB (as of 1.9).
        ## RH has a similar command named condrestart.
        if test "$1" = "condrestart"; then
            echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
        fi
        $0 status
        if test $? = 0; then
            $0 restart
        else
            rc_reset    # Not running is not a failure.
        fi
        # Remember status and be quiet
        rc_status
    ;;
    restart)
        $0 stop
        $0 start
        rc_status
    ;;
    force-reload)
        $0 reload
        rc_status
    ;;
    reload)
        echo -n "Reload of service $NAME is not supported - please restart instead "
		rc_failed 3
		rc_status -v
    ;;
    status)
        echo -n "Checking for service $NAME "
        checkproc $PERFDATA_BIN
        rc_status -v
    ;;
    probe)
        test $PERFDATA_CFG -nt $PID && echo reload
    ;;
	*)
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|probe}"
		exit 1
    ;;
esac
rc_exit	
openSUSE Build Service is sponsored by