A quick script that can be triggered to email administrators (ie: using nagios) the largest subdirectories from a parent directory. Can also simply print the results to STDOUT.

Doesn’t work with the Solaris versions of du' and sort’. :(

#!/bin/sh
TOP=20
DIR=/home/*
ADMIN=admin@host.com

if [ $1 == "-p" ]
then
  du -sc $DIR|sort -rg|grep -v total|head -n $TOP
  exit
fi

mail -s "**Space Utilization Report for `hostname`**" $ADMIN