]> arthur.barton.de Git - nagcollect.git/commitdiff
Disk Usage: check for percentage and value; better output
authorAlexander Barton <alex@barton.de>
Fri, 5 Feb 2010 17:28:23 +0000 (18:28 +0100)
committerAlexander Barton <alex@barton.de>
Fri, 5 Feb 2010 17:28:23 +0000 (18:28 +0100)
client/lib/tests/Disks.tst

index 65da26dbba92f1c2dc80f92d5d183e6e94bc29ee..99695cb8e7abd755f1d3b0364f5d773c0f851190 100644 (file)
@@ -19,25 +19,23 @@ while read x; do
        used=`echo $x | cut -d' ' -f3`
        free=`echo $x | cut -d' ' -f4`
        capacity=`echo $x | cut -d' ' -f5 | sed 's/%//'`
+       declare -i capacity2=100-$capacity
        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
+       TEXT="${TEXT}${fs} ${free} MB (${capacity2}%);"
+       [ "$free" -lt 2000 -a $capacity2 -lt 5 ] && error=1
+       [ "$free" -lt 5000 -a $capacity2 -lt 10 ] && warning=1
 done < "$TEMP"
 
 if [ -n "$error" ]; then
        STATUS=2
-       TEXT="Disk usage is CRITICAL: $TEXT"
+       TEXT="Disk usage is CRITICAL, free space: $TEXT"
 elif [ -n "$warning" ]; then
        STATUS=1
-       TEXT="Disk usage is WARNING: $TEXT"
+       TEXT="Disk usage is WARNING, free space: $TEXT"
 else
        STATUS=0
-       TEXT="Disk usage is OK: $TEXT"
+       TEXT="Disk usage is OK, free space: $TEXT"
 fi
 
 rm -f "$TEMP"