sysstat/sysstat-9.0.0-sa1sa2lock.diff

48 lines
1.3 KiB
Diff

--- sa1.in
+++ sa1.in
@@ -29,17 +29,23 @@
rm -f ${CURRENTFILE}
ln -s ${CURRENTDIR}/${CURRENTFILE} ${CURRENTFILE}
fi
+set -e
umask 0022
ENDIR=@SA_LIB_DIR@
+LOCKFILE=/var/log/sa/sadc.LOCK
cd ${ENDIR}
+
+lockfile -r2 -30 $LOCKFILE 2>/dev/null
+trap "rm -f $LOCKFILE" EXIT
+
[ "$1" = "--boot" ] && shift && BOOT=y || BOOT=n
if [ $# = 0 ] && [ "${BOOT}" = "n" ]
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...
- exec ${ENDIR}/sadc -F -L 1 1 -
+ ${ENDIR}/sadc -F -L 1 1 -
else
- exec ${ENDIR}/sadc -F -L $* -
+ ${ENDIR}/sadc -F -L $* -
fi
--- sa2.in
+++ sa2.in
@@ -48,6 +48,16 @@
DFILE=${CURRENTDIR}/${CURRENTFILE}
[ -f "$DFILE" ] || exit 0
cd ${ENDIR}
+
+LOCKFILE=/var/log/sa/sadc.LOCK
+if ! lockfile -r6 -600 $LOCKFILE 2>/dev/null; then
+ if test `find $LOCKFILE -mmin +180 2>/dev/null`; then
+ rm -f $LOCKFILE
+ logger -p cron.alert "$0: detected an old lockfile \"$LOCKFILE\"."
+ fi
+fi
+trap "rm -f $LOCKFILE" EXIT
+
[ -L ${RPT} ] && rm -f ${RPT}
${ENDIR}/sar $* -f ${DFILE} > ${RPT}
find ${DDIR} \( -name 'sar??' -o -name 'sa??' -o -name 'sar??.gz' -o -name 'sa??.gz' -o -name 'sar??.bz2' -o -name 'sa??.bz2' \) \