#!/bin/sh
#This is a shell script that checks file system capacity mounted on /home directory
#If file system is over 90% capacity, this shell script will generate notification emails sending to all users
warning()
{
fs=$1 # first argument is the file system name
fscap=$2 # second argument is the file system's capacity
for user in `ls /home`
do
echo "File system mounted on /home directory is over 90% capacity. Please be ready for system maintainance. " | mail -s "Warning! $fs here is at $fscap capacity" user
done
echo "Warning: $fs is at $fscap capacity"
}
daOslg= `df -h | sed -n '/home/p' | tr -s ' ' ' ' | cut -d' ' -f1`
daOslgCap= `df -h | sed -n '/home/p' | tr -s ' ' ' ' | cut -d' ' -f5`
if ["$daOslgCap" -gt "90%"]
then
warning $daOslg $daOslgCap
fi