#!/bin/sh

# user id's of real, not system, users
HUMAN=500

# threshold
THRESH=300000

# user:*:id:*:*:homedir:...
# 1      3      6

cat /etc/passwd |\
while read i; do
	id=`echo $i | cut -d: -f3`
	
	# skip system users
	[ "$id" -lt "$HUMAN" ] && continue;
	
	home=`echo $i | cut -d: -f6`
	free=`/bin/df $home | awk '{ print $4 }' | egrep -o '[0-9]+'`
	
	[ "$free" -lt "$THRESH" ] || continue;
	
	echo "Please check you files" |\
	mail -s "[Warning] Alailable disk space below $THRESH" `echo $i | cut -d: -f1`
done





