lucianoes

Notify Repquota by email

Apr 13th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.49 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. /usr/sbin/repquota -au |grep web| sed 's/ \+/ /g' | cut -f1,3,4 -d" " | while read LINE
  4. do
  5. USED=`echo $LINE | cut -f2 -d" "`
  6. QUOTA=`echo $LINE | cut -f3 -d" "`
  7. # TO AVOID DIVISION BY NULL LET'S INCREMENT QUOTA
  8. let "QUOTA +=1"
  9. #CALCULATE PERCENT
  10. let RESULT=USED*100/QUOTA
  11. if [ $RESULT -ge 90 ]&&[ $RESULT -lt 150 ]; then
  12. NAME=`echo $LINE | cut -f1 -d" "`
  13. # SEND MAIL
  14. SUBJ="-= Your mailbox is full =-"
  15. mutt -s "$SUBJ" $NAME@example.com < /usr/src/scripts/message.txt
  16. fi
  17. done
Advertisement
Add Comment
Please, Sign In to add comment