#!/bin/bash

highdisk=`cat /dev/null`
> /tmp/highdisk.txt
df -x devtmpfs -x tmpfs -h | grep -v "/vz/root"| grep -v Filesystem | while read disk
do
        perc=`echo $disk | awk {'print $5'} |cut -d% -f1`
		partn=`echo $disk | awk {'print $6'} |cut -d% -f1`

#       echo "perc: $perc"
        if [[ $perc -ge 95 ]]; then
			if [[ $partn != '/backup' ]]; then
				highdisk="$highdisk -- Partition `echo $disk | awk {'print $1'}` mounted on `echo $disk | awk {'print $6'}` is $perc filled"
			fi
			if [[ $partn == '/backup' && $perc -gt 97 ]]; then
				highdisk="$highdisk -- Partition `echo $disk | awk {'print $1'}` mounted on `echo $disk | awk {'print $6'}` is $perc filled"
			fi
        else
                disksize=good
        fi
        
#		if [[ $perc -ge 95 ]]; then
#                highdisk="$highdisk -- Partition `echo $disk | awk {'print $1'}` mounted on `echo $disk | awk {'print $6'}` is $perc filled"
#        else
#                disksize=good
#        fi
        echo "$highdisk" > /tmp/highdisk.txt
done


if [ "$( cat /tmp/highdisk.txt )" ]; then
        echo "Critical: `cat /tmp/highdisk.txt`"
        exit 2
else
        echo "OK: All disk partitions have been found to be fine."
        exit 0
fi
