From 9d7da25fa8156c07750c3d007097bd3c90a23890 Mon Sep 17 00:00:00 2001 From: Adrian Muraru Date: Sun, 15 Jun 2014 17:06:40 +0300 Subject: [PATCH] Write test should fail on timeout --- check_mountpoints.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/check_mountpoints.sh b/check_mountpoints.sh index aa6f383..4915de3 100755 --- a/check_mountpoints.sh +++ b/check_mountpoints.sh @@ -268,10 +268,19 @@ for MP in ${MPS} ; do elif [ ${WRITETEST} -eq 1 ]; then ## if wanted, check if it is writable TOUCHFILE=${MP}/.mount_test_from_$(hostname) - touch ${TOUCHFILE} &>/dev/null - if [ $? -ne 0 ]; then + touch ${TOUCHFILE} &>/dev/null & + TOUCHPID=$! + for (( i=1 ; i<$TIME_TILL_STALE ; i++ )) ; do + if ps -p $TOUCHPID > /dev/null ; then + sleep 1 + else + break + fi + done + if ps -p $TOUCHPID > /dev/null ; then + $(kill -s SIGTERM $TOUCHPID &>/dev/null) log "CRIT: ${TOUCHFILE} is not writable." - ERR_MESG[${#ERR_MESG[*]}]="${TOUCHFILE} is not writable." + ERR_MESG[${#ERR_MESG[*]}]="Could not write in ${MP} in $TIME_TILL_STALE sec. Seems to be stale." else rm ${TOUCHFILE} &>/dev/null fi