#!/bin/bash
#More at https://linuxtm.ro
ROOT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
DATADISK=$(df /var/www | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=85

#Monitor root partition
if [ "$ROOT" -gt "$THRESHOLD" ] ; then
    mail -E -s 'Disk Space Alert' mail@example.com << EOF
Your root partition remaining free space is critically low. Used: $ROOT%
EOF
fi

#Monitor mounted disk
if [ "$DATADISK" -gt "$THRESHOLD" ] ; then
    mail -E -s 'Disk Space Alert' mail@example.com << EOF
Your datadisk partition remaining free space is critically low. Used: $DATADISK%
EOF
fi