#!/bin/sh
#
# sysstat       Sysstat system monitoring utility
#
# chkconfig:	2345 35 55
#
# description:	Sysstat system monitoring tools (sar,iostat,mpstat) \
#

# Source function library
. /etc/rc.d/init.d/functions


# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/sysstat ]; then
		msg_starting "system activity data collector"
		daemon /usr/lib/sa/sadc
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sysstat
	else
		msg_already_running "system activity data collector"
		exit 1
	fi
	;;
  stop)
        # Stop daemons.
        if [ -f /var/lock/subsys/sysstat ]; then
                msg_stopping "system activity data collector"
		echo
                rm -f /var/lock/subsys/sysstat >/dev/null 2>&1
        else
                msg_not_running "system activity data collector"
                exit 1
        fi
	;;
  status)
	status sysstat
	;;
  restart)
	$0 stop
	$0 start
	;;
  *)
	msg_usage "$0 {start|stop|status|restart}"
	exit 1
esac

exit $RETVAL
