#!/bin/bash #set -v #Creating for loop to include all users for each in `ls /backup |grep -v aquota | grep -v lost` do #Creating variable A = disk space used by user A=`/usr/sbin/repquota -a |grep "$each " | sed -e 's/ * / /g' | /bin/cut -f 3 -d " "` #Creating variable B = disk space allocated to user B=`/usr/sbin/repquota -a |grep "$each " | sed -e 's/ * / /g' | /bin/cut -f 4 -d " "` #echo commands for troubleshooting purposes echo $each echo "User is using $A bytes" echo "User is allowed $B bytes" #First if statement to find out if there is a quota set for user if [ $B -ne 0 ] ; then #Second if statment to find out if Disk space used is equal to or greater than the space allocated to the customer if [ $A -ge $B ] ; then #echoing the body of the email and sending it to the mail command. The subject includes the user and the hostname echo "Hello, We are sending you this email to inform you that you have reached disk space quota on `hostname`. Please check on your backups as they might not be working correctly. If you would like to add more disk space to your storage account please email support@sagonet.com Thank you Sago Networks" | mail $each -s "User $each is over quota on `hostname`" #output for troubleshooting purposes echo "CUSTOMER IS OVER QUOTA" else #output for troubleshooting purposes echo "Customer is not over quota" fi else #output for troubleshooting purposes echo "Customer is not over quota" fi done