2004-09-09 10:47:19 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# psacct Script to control kernel process accounting
|
|
|
|
#
|
|
|
|
# Author: Mike A. Harris <mharris@redhat.com>
|
|
|
|
#
|
|
|
|
# chkconfig: - 90 10
|
|
|
|
# description: Starts and stops process accounting
|
2007-07-25 07:08:51 +00:00
|
|
|
# short-description: Starts and stops process accounting
|
|
|
|
|
2009-09-16 07:20:45 +00:00
|
|
|
### BEGIN INIT INFO
|
2010-03-05 12:26:07 +00:00
|
|
|
# Required-Start:
|
|
|
|
# Required-Stop:
|
|
|
|
# Provides: psacct
|
|
|
|
# Default-Start:
|
|
|
|
# Default-Stop: 0 1 2 3 4 5 6
|
2009-09-16 07:20:45 +00:00
|
|
|
# Description: Starts and stops process accounting
|
|
|
|
# Short-Description: Starts and stops process accounting
|
|
|
|
### END INIT INFO
|
2004-09-09 10:47:19 +00:00
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/init.d/functions
|
|
|
|
|
|
|
|
# The location of the accounting file
|
|
|
|
ACCTFILE=/var/account/pacct
|
2007-07-25 07:08:51 +00:00
|
|
|
LOCKFILE=/var/lock/subsys/psacct
|
2004-09-09 10:47:19 +00:00
|
|
|
|
2004-09-09 10:48:16 +00:00
|
|
|
start() {
|
2004-09-09 10:47:24 +00:00
|
|
|
[ ! -r $ACCTFILE ] && touch $ACCTFILE && chmod 600 $ACCTFILE
|
2007-07-25 07:08:51 +00:00
|
|
|
if [ -r $ACCTFILE ]; then
|
|
|
|
action $"Starting process accounting: " /sbin/accton $ACCTFILE
|
|
|
|
RETVAL=$?
|
|
|
|
if [ $RETVAL -eq 0 ]; then
|
|
|
|
touch $LOCKFILE
|
|
|
|
else
|
2009-09-16 07:20:45 +00:00
|
|
|
exit 7
|
2007-07-25 07:08:51 +00:00
|
|
|
fi
|
|
|
|
else
|
2009-09-16 07:20:45 +00:00
|
|
|
exit 4
|
2007-07-25 07:08:51 +00:00
|
|
|
fi
|
2004-09-09 10:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2007-07-25 07:08:51 +00:00
|
|
|
|
2010-01-04 13:35:55 +00:00
|
|
|
action $"Shutting down process accounting: " /sbin/accton off
|
2007-07-25 07:08:51 +00:00
|
|
|
RETVAL=$?
|
|
|
|
if [ $RETVAL -eq 0 ]; then
|
|
|
|
rm -f $LOCKFILE
|
2009-09-16 07:20:45 +00:00
|
|
|
else
|
|
|
|
exit 1
|
2007-07-25 07:08:51 +00:00
|
|
|
fi
|
2004-09-09 10:48:16 +00:00
|
|
|
}
|
2007-07-25 07:08:51 +00:00
|
|
|
|
2004-09-09 10:48:16 +00:00
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
2004-09-09 10:47:19 +00:00
|
|
|
;;
|
|
|
|
status)
|
2007-07-25 07:08:51 +00:00
|
|
|
if [ -e $LOCKFILE ]; then
|
2004-09-09 10:47:19 +00:00
|
|
|
echo $"Process accounting is enabled."
|
|
|
|
else
|
|
|
|
echo $"Process accounting is disabled."
|
2007-07-25 07:30:12 +00:00
|
|
|
exit 3
|
2004-09-09 10:47:19 +00:00
|
|
|
fi
|
|
|
|
;;
|
2010-04-19 09:21:22 +00:00
|
|
|
restart|reload|force-reload)
|
2004-09-09 10:47:19 +00:00
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# do not advertise unreasonable commands that there is no reason
|
|
|
|
# to use with this device
|
2010-04-19 09:21:22 +00:00
|
|
|
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}"
|
2009-09-16 07:20:45 +00:00
|
|
|
exit 2
|
2004-09-09 10:47:19 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|