]> arthur.barton.de Git - nagcollect.git/blob - client/lib/tests/Darwin/DiskErrors.tst
DiskErrors.tst: same grep expressions for reboot/no-reboot case
[nagcollect.git] / client / lib / tests / Darwin / DiskErrors.tst
1 # NagCollect -- Nagios Data Collector for Passive Checks
2 # Copyright (c)2010-2011 Alexander Barton, alex@barton.de
3
4 # Check disks for I/O errors
5
6 SERVICE="Disks_p"
7
8 grepcmd='grep -i "I/O" | grep -i error | grep -v nagcollect
9  | grep -v "com.apple.mdworker.pool"
10  | grep -v "file i/o error - bad dset location"
11  | grep -v "encoder error"
12 '
13
14 offset=`LC_ALL=C grep -b "BOOT_TIME:" /var/log/system.log \
15  | tail -n 1 | cut -d':' -f1`
16 [ -n "$offset" ] || offset=`LC_ALL=C grep -b -- --NagiosReset-- \
17  /var/log/system.log | tail -n 1 | cut -d':' -f1`
18
19 if [ -n "$offset" ]; then
20         # reboot detected in system.log
21         error=`LC_ALL=C tail -c "+$offset" /var/log/system.log \
22          | eval $grepcmd | tail -n 1`
23 else
24         # no reboot detected in system.log
25         error=`LC_ALL=C grep -i "I/O" /var/log/system.log \
26          | eval $grepcmd | tail -n 1`
27 fi
28 if [ -n "$error" ]; then
29         msg=`echo $error | cut -d' ' -f6-`
30         STATUS=2
31         TEXT="ERROR - $msg"
32 else
33         STATUS=0
34         TEXT="OK - No I/O errors detected."
35 fi