I'm just sharing.
We run this script every 5 min via cron on our Zimbra servers. It checks the disk usage on our Zimbra volumes, and then emails us when those thresholds are reached.
I've left in all the comments so you can see what we use and don't use anymore. I'm sure that there are better ways to do this, so by all means let me know.
Code:
#! /bin/ksh
#
## ALTERED 03/14/2005 by NRC to catch any file system
## ALTERED 11/17/2004 for use at Franklin University by D.Morgenstern, A.Kelly and F.S.
########### Function SENDMAIL will send mail to sys admins regarding disk capacity ##############
SENDMAIL () {
mail -s "$HOST Disk Space Alert" $INTERESTED<<EOF
$HOST Disk Space Alert
Filesystem $FILESYSTEM has reached $PERC% of its capacity.
EOF
return
}
########## VARIABLES ###########
# phone page phonenumber1/ fs; phonenumber2/ak; phonenumber3/dm; phonenumber4/rc
INTERESTED=emailaddress1,distributionlist1
HOST=`uname -n`
######### Run df -kl and extract filesystem and disk usage amount to temporary holding file ########
df -Plk | grep -iv filesystem | awk '{ print $6"\t "$5}'|cut -d"%" -f1 >holding
######### reasign standard input to temporary holding file#######
exec < holding
######### Read FILESYSTEM and PERCentage, for each line execute the case test ########
while read FILESYSTEM PERC
do
######## Test each FILESYSTEM PERCentage against it's threshold amount. If PERCentage is
######## greater than threshold amount execute the SENDMAIL function.
case "$FILESYSTEM" in
/) if [[ $PERC -gt 90 ]]; then
SENDMAIL
fi;;
/var/run) if [[ $PERC -gt 70 ]]; then
SENDMAIL
fi;;
/tmp) if [[ $PERC -gt 80 ]]; then
SENDMAIL
fi;;
/var) if [[ $PERC -gt 90 ]]; then
SENDMAIL
fi;;
/usr) if [[ $PERC -gt 90 ]]; then
SENDMAIL
fi;;
/ZimbraBackup) if [[ $PERC -gt 97 ]]; then
SENDMAIL
fi;;
/zimbraPrimary) if [[ $PERC -gt 90 ]]; then
SENDMAIL
fi;;
/zimbraRedolog) if [[ $PERC -gt 75 ]]; then
SENDMAIL
fi;;
/zimbraIndex) if [[ $PERC -gt 95 ]]; then
SENDMAIL
fi;;
/zimbraHSM1) if [[ $PERC -gt 98 ]]; then
SENDMAIL
fi;;
/opt) if [[ $PERC -gt 94 ]]; then
SENDMAIL
fi;;
*) if [[ $PERC -gt 90 ]]; then
SENDMAIL
fi;;
# mail -s 'Invalid FILESYSTEM! found' $INTERESTED<<EOF
#
# Filesystem $FILESYSTEM has been discovered by the Diskmonitor Process.
#EOF
#
esac
done