]> arthur.barton.de Git - nagcollect.git/commitdiff
New "Disks" test that checks the free space of filesystems
authorAlexander Barton <alex@barton.de>
Fri, 5 Feb 2010 16:37:32 +0000 (17:37 +0100)
committerAlexander Barton <alex@barton.de>
Fri, 5 Feb 2010 16:37:32 +0000 (17:37 +0100)
client/lib/tests/Disks.tst [new file with mode: 0644]

diff --git a/client/lib/tests/Disks.tst b/client/lib/tests/Disks.tst
new file mode 100644 (file)
index 0000000..65da26d
--- /dev/null
@@ -0,0 +1,43 @@
+# NagCollect -- Nagios Data Collector for Passive Checks
+# Copyright (c)2009 Alexander Barton, alex@barton.de
+
+# Check free space on local filesystems
+
+SERVICE="DiskUsage_p"
+STATUS=4
+
+error=
+warning=
+
+TEMP="/tmp/$$.tmp"
+
+df -l -P -m | grep "^/" >"$TEMP"
+
+while read x; do
+       fs=`echo $x | cut -d' ' -f1`
+       blocks=`echo $x | cut -d' ' -f2`
+       used=`echo $x | cut -d' ' -f3`
+       free=`echo $x | cut -d' ' -f4`
+       capacity=`echo $x | cut -d' ' -f5 | sed 's/%//'`
+       fs=`echo $x | cut -d' ' -f6`
+       [ -n "$TEXT" ] && TEXT="$TEXT "
+       TEXT="${TEXT}${fs} ${free} MB (${capacity}%);"
+       if [ "$capacity" -gt 95 ]; then
+               error=1
+       elif [ "$capacity" -gt 90 ]; then
+               warning=1
+       fi
+done < "$TEMP"
+
+if [ -n "$error" ]; then
+       STATUS=2
+       TEXT="Disk usage is CRITICAL: $TEXT"
+elif [ -n "$warning" ]; then
+       STATUS=1
+       TEXT="Disk usage is WARNING: $TEXT"
+else
+       STATUS=0
+       TEXT="Disk usage is OK: $TEXT"
+fi
+
+rm -f "$TEMP"