#!/bin/sh
# /usr/lib/sa/sa1.sh
# (C) 1999-2005 Sebastien Godard (sysstat <at> wanadoo.fr)
#
set -e
umask 0022
DATE=`date +.%Y_%m_%d`
ENDIR=/usr/lib/sa
DFILE=/var/log/sa/sa${DATE}
LOCKFILE=/var/log/sa/sadc.LOCK

cd ${ENDIR}
lockfile -r2 -30 $LOCKFILE 2>/dev/null
trap "rm -f $LOCKFILE" EXIT

if [ $# = 0 ]
then
# Note: Stats are written at the end of previous file *and* at the
# beginning of the new one (when there is a file rotation) only if
# outfile has been specified as '-' on the command line...
	${ENDIR}/sadc -F -L 1 1 ${DFILE}
else
	${ENDIR}/sadc -F -L $* ${DFILE}
fi
