The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 02-08-2008
vivsiv vivsiv is offline
Registered User
  
 

Join Date: Jun 2006
Location: Los Angeles
Posts: 17
here's a script

#!/bin/ksh
TEMPDIR=$HOME
FILE=mail.log
sendemail=-1
HOSTNAME="vivek" ###ur unix server name
space=`df -bhk /users/directory |awk '{print$5}'` ## dir were u want to monitor
echo "$space is the file size percent"
#capacity=${space%?}
#capacity=$space|/usr/xpg4/bin/awk -F"[%]" '{ print $1}'
capacity=`df -bhk /users/directory| grep directory |awk '{print $5}'|sed 's/\%//'`

echo "capacity in $HOSTNAME is $capacity " >> $TEMPDIR/$FILE
if [ $capacity -gt 90 ]; then
echo "alert space in $HOSTNAME getting full "
echo > $TEMPDIR/$FILE
echo "*************************************************" >> $TEMPDIR/$FILE
echo "Problem with siebel disk space on $HOSTNAME" >> $TEMPDIR/$FILE
/usr/bin/mailx -s "ALERT: Problem with file space on $HOSTNAME " "vivek@unix.com" < $TEMPDIR/$FILE
else
echo "enough space available"
fi