Guros,
I've just finished with this script for maintaining our filesystems and monitoring them not to exceed 95% in size. In addition i'm keeping the filesystems history to observe the increase to predict future expansion.
I thought of sharing it with you to see your way of dealing with the same issues and if there any enhancement to make to my script from your experience.
Regards,
Khalid
I've just finished with this script for maintaining our filesystems and monitoring them not to exceed 95% in size. In addition i'm keeping the filesystems history to observe the increase to predict future expansion.
I thought of sharing it with you to see your way of dealing with the same issues and if there any enhancement to make to my script from your experience.
Code:
df -Pk | awk '$3 ~ /[0-9]/ { print $1,"\t",$3,"\t",substr($5,1,index($5,"%")-1)
}' > df.out
set -A new1 $( awk ' {print $1}' df.out )
set -A new2 $( awk ' {print $2}' df.out )
set -A new3 $( awk ' {print $3}' df.out )
if [[ ! -s out ]]
then
j=0;
cat /dev/null > out
while [[ $j -lt ${#new1[*]} ]]
do
print "${new1[$j]}\t${new2[$j]}" >> out
((j+=1))
done
fi
set -A old1 $( awk ' {print $1}' out )
set -A old2 $( awk ' {print $2}' out )
cat /dev/null > email.txt
i=0;
while [[ $i -lt ${#old1[*]} ]]
do
j=0;
while [[ $j -lt ${#new1[*]} ]]
do
if [[ ${old1[$i]} = ${new1[$j]} ]]
then
if [[ ${old2[$i]} -lt ${new2[$j]} ]]
then
(( temp = ${new2[$j]} - ${old2[$i]} ))
print "${old1[$i]} was increased in size by ${temp}KByte" >> email.txt
break
fi
fi
((j+=1))
done
((i+=1))
done
j=0;
cat /dev/null > out
while [[ $j -lt ${#new1[*]} ]]
do
# This if statement is for Handling exceptions
#(where not to check for higher than 95% filesystems)
if [[ ${new1[$j]} != "server22:/backup" ]]
then
if [[ ${new3[$j]} -ge 95 ]]
then
print "WARNING: ${new1[$j]} is ${new3[$j]}% utilized!!!" >> email.txt
fi
fi
print "${new1[$j]}\t${new2[$j]}" >> out
((j+=1))
done
#cat email.txt
if [[ -s email.txt ]]
then
mail -s "Daily Status Report" "khalid@mycompany.com" < email.txt
if
# History
echo "======================================================================" >> history.out
date >> history.out
echo "======================================================================" >> history.out
cat email.txt >> history.out
echo "======================================================================" >> history.out
df -Pg >> history.out
# Maintain the size of the history.out file to be 3000 lines only
tail -3000 history.out > temp.out
mv temp.out history.out
Regards,
Khalid