Disk usage

#!/bin/sh
2# set -x
3# Shell script to monitor or watch the disk space
4# It will send an email to $ADMIN, if the (free available) percentage of space is >= 90%.
5# -------------------------------------------------------------------------
6# Set admin email so that you can get email.
7ADMIN="root"
8# set alert level 90% is default
9ALERT=90
10# Exclude list of unwanted monitoring, if several partions then use "|" to separate the partitions.
11# An example: EXCLUDE_LIST="/dev/hdd1|/dev/hdc5"
12EXCLUDE_LIST="/auto/ripper"
13#
14#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
15#
16function main_prog() {
17while read output;
18do
19#echo $output
20  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1)
21  partition=$(echo $output | awk '{print $2}')
22  if [ $usep -ge $ALERT ] ; then
23     echo "Running out of space "$partition ($usep%)" on server $(hostname), $(date)" |
24     mail -s "Alert: Almost out of disk space $usep%" $ADMIN
25  fi
26done
27}
28if [ "$EXCLUDE_LIST" != "" ] ; then
29  df -H | grep -vE "^Filesystem|tmpfs|cdrom|${EXCLUDE_LIST}" | awk '{print $5 " " $6}' | main_prog
30else
31  df -H | grep -vE "^Filesystem|tmpfs|cdrom" | awk '{print $5 " " $6}' | main_prog

32fi