#!/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

RETVAL=0
# 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"
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/sysstat ]; then
		# Stop daemons.
		msg_stopping "system activity data collector"
		ok
		rm -f /var/lock/subsys/sysstat >/dev/null 2>&1
	else
		msg_not_running "system activity data collector"
	fi
	;;
  status)
	status sysstat
	exit $?
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
	;;
esac

exit $RETVAL
