You are on page 1of 1

#!

/usr/bin/ksh
#
# SCRIPT: fs_mon_HP.ksh
# AUTHOR: Indrajit Bhagat
# DATE: 15-10-2010
# REV: 1.1.P
# PURPOSE: This script is used to monitor for full filesystems,
# which is defined as .exceeding. the FSMAX value.
# A message is displayed for all .full. filesystems.
#
# REV LIST:
#
# set -n # Uncomment to check syntax without any execution
# set -x # Uncomment to debug this script
#
##### DEFINE FILES AND VARIABLES HERE ####
FSMAX="50"
# Max. FS percentage value
WORKFILE="/tmp/df.work"
# Holds filesystem data
>$WORKFILE
# Initialize to empty
OUTFILE="/tmp/df.outfile"
# Output display file
>$OUTFILE # Initialize to empty
THISHOST=`hostname` # Hostname of this machine
######## START OF MAIN #############
bdf | tail +2 |awk '{print $1, $2, $4, $5, $6}' > $WORKFILE
# Loop through each line of the file and compare column 2
while read FSDEVICE FSVALUE FSMOUNT
do
FSVALUE=$(echo $FSVALUE | sed s/\%//g) # Remove the % sign typeset -i FSVALUE
if [ $FSVALUE -gt $FSMAX ]
then
echo "$FSDEVICE mounted on $FSMOUNT is ${FSVALUE}%" \
>> $OUTFILE
fi
done < $WORKFILE # Feed the while loop from the bottom!!
if [[ -s $OUTFILE ]]
then
echo "\nFull Filesystem(s) on $THISHOST\n"
cat $OUTFILE
print
fi

You might also like