]> arthur.barton.de Git - nagcollect.git/blob - client/lib/tests/Darwin/DiskErrors.tst
Remove OS X packaging scripts
[nagcollect.git] / client / lib / tests / Darwin / DiskErrors.tst
1 # NagCollect -- Nagios Data Collector for Passive Checks
2 # Copyright (c)2010-2012 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  | grep -v "SQLite error code:"
13 '
14
15 offset=`LC_ALL=C grep -b "BOOT_TIME:" /var/log/system.log \
16  | tail -n 1 | cut -d':' -f1`
17 [ -n "$offset" ] || offset=`LC_ALL=C grep -b -- --NagiosReset-- \
18  /var/log/system.log | tail -n 1 | cut -d':' -f1`
19
20 if [ -n "$offset" ]; then
21         # reboot detected in system.log
22         error=`LC_ALL=C tail -c "+$offset" /var/log/system.log \
23          | eval $grepcmd | tail -n 1`
24 else
25         # no reboot detected in system.log
26         error=`LC_ALL=C grep -i "I/O" /var/log/system.log \
27          | eval $grepcmd | tail -n 1`
28 fi
29 if [ -n "$error" ]; then
30         msg=`echo $error | cut -d' ' -f6-`
31         STATUS=2
32         TEXT="ERROR - $msg"
33 else
34         STATUS=0
35         TEXT="OK - No I/O errors detected."
36 fi