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