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