The following shell scrip will check the disk space and change the variable diskfull
to 1
if the usage is more than 10%
The last echo always shows
you can do it this way with gawk(no need to use grep). for alerts you can send email to root.
threshold=10
df -HP | awk -v t="$threshold" -v msg="" 'NR>1 && $5+0 > t{
msg=msg $1" is "$5"\n"
}END{print msg}' | mail root
or check whether there is "msg" or not first
threshold=10
result=$(df -HP | awk -v t="$threshold" -v msg="" 'NR>1 && $5+0 > t{
msg=msg $1" is "$5"\n"
}END{print msg}')
if [ -n "$result" ];then
echo "Overload"
echo "$result" | mail root
fi