sysstat/sysstat-8.1.6-sa1sa2lock.diff
David Anes a7536043f1 - Updated sysstat-8.1.6-sa1sa2lock.diff to use flock to create the
lockfile. Using lockfile would require additional SELinux permissions.
  Require util-linux instead of procmail for this (bsc#1228246)

OBS-URL: https://build.opensuse.org/package/show/Base:System/sysstat?expand=0&rev=153
2024-08-21 17:02:15 +00:00

63 lines
1.8 KiB
Diff

Index: sysstat-12.7.5/sa1.in
===================================================================
--- sysstat-12.7.5.orig/sa1.in
+++ sysstat-12.7.5/sa1.in
@@ -31,8 +31,16 @@ then
LONG_NAME=y
fi
+set -e
ENDIR=@SA_LIB_DIR@
cd ${ENDIR}
+LOCKFILE=/var/run/sysstat/sadc.LOCK
+mkdir -p /var/run/sysstat
+touch "$LOCKFILE"
+exec 4<>"$LOCKFILE"
+flock -w 60 4
+trap "/bin/rm -f $LOCKFILE" EXIT
+
[ "$1" = "--boot" ] && shift && BOOT=y || BOOT=n
[ "$1" = "--sleep" ] && shift && SLEEP=y || SLEEP=n
@@ -51,13 +59,13 @@ fi
if [ "${SLEEP}" = "y" ]
then
- exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} -C "LINUX SLEEP MODE ($*)" ${SA_DIR}
+ ${ENDIR}/sadc -F -L ${SADC_OPTIONS} -C "LINUX SLEEP MODE ($*)" ${SA_DIR}
elif [ $# = 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 not been explicitly specified on the command line...
- exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} 1 1 ${SA_DIR}
+ ${ENDIR}/sadc -F -L ${SADC_OPTIONS} 1 1 ${SA_DIR}
else
- exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} $* ${SA_DIR}
+ ${ENDIR}/sadc -F -L ${SADC_OPTIONS} $* ${SA_DIR}
fi
Index: sysstat-12.7.5/sa2.in
===================================================================
--- sysstat-12.7.5.orig/sa2.in
+++ sysstat-12.7.5/sa2.in
@@ -59,6 +59,19 @@ fi
[ -f "${DFILE}" ] || exit 0
cd ${ENDIR}
+
+LOCKFILE=/var/run/sysstat/sadc.LOCK
+mkdir -p /var/run/sysstat
+touch "$LOCKFILE"
+exec 4<>"$LOCKFILE"
+if ! flock -w 3600 4; 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 "/bin/rm -f $LOCKFILE" EXIT
+
if [ x${REPORTS} != xfalse ]
then
S_REPEAT_HEADER=${REPEAT_HEADER} ${ENDIR}/sar $* -f ${DFILE} > ${RPT}