The sar scripts /usr/lib/sa/sa1 and sa2 both normally use logs in
/var/log/sa itself, but if HISTORY is > 28 , the scripts use a tree of
log directories under /var/log/sa.
When HISTORY is < 28, then /usr/lib/sa/sa2's action to expunge old logs
which are more than HISTORY days old will mean that "tomorrow's" saXX
file never exists prior to /usr/lib/sa/sa1 creating it on the first pass
of the day.
However, when HISTORY == 28, then on March 1st in a non-leap year, the
log file sa01 will already exist from Feb 1st having not been
pre-expunged by the sa2 script. Similarly for March 2nd through 28th.
So now make sure that the sa1 script deletes the log file
if it is from a previous month. This way this will
prevent a log file from a month ago being re-used "today".
# Used only if ${SYSCONFIG_DIR}/sysstat doesn't exist!
HISTORY=0
SADC_OPTIONS=""
-
+DDIR=@SA_DIR@
+DATE=`date +%d`
+CURRENTFILE=sa${DATE}
+CURRENTDIR=`date +%Y%m`
SYSCONFIG_DIR=@SYSCONFIG_DIR@
+
[ -r ${SYSCONFIG_DIR}/sysstat ] && . ${SYSCONFIG_DIR}/sysstat
if [ ${HISTORY} -gt 28 ]
then
- CURRENTDIR=`date +%Y%m`
- DATE=`date +%d`
- CURRENTFILE=sa${DATE}
- DDIR=@SA_DIR@
cd ${DDIR} || exit 1
[ -d ${CURRENTDIR} ] || mkdir -p ${CURRENTDIR}
# If ${CURRENTFILE} exists and is a regular file, then make sure
# the (new) current file
rm -f ${CURRENTFILE}
ln -s ${CURRENTDIR}/${CURRENTFILE} ${CURRENTFILE}
+else
+ # If ${CURRENTFILE} exists, is a regular file and is from a previous
+ # month then delete it so that it is recreated by sadc afresh
+ [ -f ${CURRENTFILE} ] && [ "`date +%Y%m -r ${CURRENTFILE}`" -lt "${CURRENTDIR}" ] && rm -f ${CURRENTFILE}
fi
umask 0022
ENDIR=@SA_LIB_DIR@