#/bin/bash
####################################################################### 
# Name: diskspacechecker.sh
#
# Requirements: None
#
# Description: Checks and reports on the partition with the lowest
# free space.
# 
# Usage: diskspacechecker.sh
#
# Notes: Modified for purposes of presentation at local lug meeting.
#
# Author: Unknown, found at
# http://tldp.org/LDP/Bash-Beginners-Guide/html/index.html
#
# License: GPL
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
####################################################################### 
space=`df -h | awk '{print $5}' | grep % | grep -v Use | sort -n | tail -1 | cut -d "%" -f1 -`

case $space in
	[1-6]?[0-9])
		Message="All is quiet." ;;
	[7-8][0-9])
		Message="Start thinking about cleaning out some stuff.  There's a partition that is $space % full." ;;
	9[1-8])
		Message="Better hurry with that new disk...  One partition is $space % full." ;;
	99)
		Message="I'm drowning here!  There's a partition at $space %!" ;;
	*)
		Message="I seem to be running with an nonexitent amount of disk space..." ;;
esac
echo $Message

