Sophie

Sophie

distrib > Mandriva > current > x86_64 > by-pkgid > 7e26efb37d341018703ae869a9607e64 > files > 2

collectl-3.4.0-1mdv2010.1.noarch.rpm

#!/bin/sh
# Startup script for collectl
#

### BEGIN INIT INFO
# Provides:          collectl
# Required-Start:    $network +openibd
# Required-Stop:     $network +openibd
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Collectl monitors system performance.
# Description:       Collectl is a light-weight performance monitoring
#                    tool capable of reporting interactively as well 
#                    as logging to disk. It reports statistics on 
#                    cpu, disk, infiniband, lustre, memory, network,
#                    nfs, process, quadrics, slabs and more in easy 
#                    to read format.
#
### END INIT INFO

# chkconfig: 345 99 99
# description: Run data collection for a number of subsystems
#    see /etc/collectl.conf for startup options
#      $2: process name extension, if other than collectl [optional for start/restart/reload]
#      $3: parameters, in quotes if more than one, to pass to daemon command

RETVAL=0
COLLECTL=/usr/bin/collectl
. /etc/rc.d/init.d/functions

# older distros do not support "status -p" and we need to know if this one does
STATUS=`status` 
if [[ $STATUS = *-p* ]]; then IFLAG=1; else IFLAG=0; fi
if [ $IFLAG -eq 0 ] && [ "$3" != '' ]; then 
    gprintf "starting multiple instances with this distro is not supported\n";
    exit
fi

if [ ! -f $COLLECTL ]; then
    gprintf "Cannot find %s" "$COLLECTL"
    exit 1
fi

PNAME=collectl
if [ "$2" != "" ]; then
    EXT=$2
    if [ "$1" = "start" ] || [ "$1" = "restart" ] || [ "$1" = "reload" ]; then
        if [ "$3" = "" ]; then
	    SWITCHES=$2
	    EXT=""
	else
	    SWITCHES=$3
	fi
    fi

    # Just to make sure nothing is different when running 'collectl', we 
    # won't use --check even though it's probably ok to use all the time.
    if [ "$EXT" != "" ]; then
	PNAME="collectl-$EXT"
	PSWITCH="--pname $EXT"
	CHECK="--check $PNAME "
    fi
fi
PIDFILE="/var/run/$PNAME.pid"

case "$1" in
   start)
      COMMAND="$COLLECTL -D $SWITCHES $PSWITCH"
      gprintf "Starting %s:" "$PNAME"
      daemon $CHECK$COMMAND
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$PNAME
      ;;

  stop)
      if [ -f $PIDFILE ]; then
          gprintf "Shutting down %s: " "$PNAME"
          killproc $PNAME
          RETVAL=$?
          echo
          [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PNAME
      else
          gprintf "%s does not appear to be running so will not be shut down\n" "$PNAME"
      fi
      ;;

  flush)
      if [ -f $PIDFILE ]; then
	  pid=`cat $PIDFILE`
	  echo Flushing buffers for $PNAME
	  kill -s USR1 $pid
      else
	  gprintf "Can't find pid file %s\n" "$PIDFILE"
      fi
      ;;

  restart|reload)
   	$0 stop $EXT
   	$0 start "$2" "$3"
   	RETVAL=$?
	;;
  status)
        # need to use pid file since there can be multiple instances, but only if
        # this distro supports it
        if [ $IFLAG -eq 1 ]; then
	    status -p $PIDFILE
	else
	    status $PNAME
        fi 
   	RETVAL=$?
	;;
  *)
	gprintf "Usage: %s {start|stop|flush|restart|status}\n" "$0"
	exit 1
esac

exit $RETVAL