Only test for I/O errors since last system boot
authorAlexander Barton <alex@barton.de>
Wed, 16 Dec 2009 18:19:10 +0000 (19:19 +0100)
committerAlexander Barton <alex@barton.de>
Wed, 16 Dec 2009 18:19:10 +0000 (19:19 +0100)
client/lib/tests/Disks.tst

index 297aae2..d081608 100644 (file)
@@ -3,7 +3,17 @@
 
 if [ `uname` = "Darwin" ]; then
        SERVICE="Disks_p"
-       error=`LC_ALL=C grep "I/O" /var/log/system.log | grep -v nagcollect | tail -n 1`
+       offset=`LC_ALL=C grep -b "BOOT_TIME:" /var/log/system.log \
+        | tail -n 1 | cut -d':' -f1`
+       if [ -n "$offset" ]; then
+               # reboot detected in system.log
+               error=`LC_ALL=C tail -c "+$offset" /var/log/system.log \
+                | grep "I/O" | grep -v nagcollect | tail -n 1`
+       else
+               # no reboot detected in system.log
+               error=`LC_ALL=C grep "I/O" /var/log/system.log \
+                | grep -v nagcollect | tail -n 1`
+       fi
        if [ -n "$error" ]; then
                msg=`echo $error | cut -d' ' -f6-`
                STATUS=2