Pavan DBA's Blog

The DBA Knowledge Store

Posts Tagged ‘Script to check mount point space and get email’

Script to check mount point space and get email

Posted by Pavan DBA on March 9, 2012


 

######################################

SCRIPT FOR CHECKING DISK SPACE IN UNIX

######################################

 

#!/bin/ksh

#rm /tmp/dfk.txt

#echo “df -k output for `date` `uname -n`” > /tmp/dfk.txt

echo “File system usage exceeded the threshold on `uname -n` server- `date`” > /tmp/dfk.txt

echo “” >> /tmp/dfk.txt

i=1

while [ $i -le `df -k | grep -v proc | grep -v capacity | wc -l` ] ;do

if [ `df -k | grep -v proc | grep -v capacity | head -n $i | tail -1 | awk ‘{print $5}’ | \

sed -e ‘s/%//’` -gt 97 ] ; then

#echo “File system usage exceeded the threshold on `uname -n` server- `date`” > /tmp/dfk.txt

#echo “” >> /tmp/dfk.txt

df -k | grep -v proc | grep -v capacity | head -n $i | tail -1 >> /tmp/dfk.txt

fi

((i=i+1))

done

if [ `cat /tmp/dfk.txt | wc -l` -gt 2 ] ; then

cat /tmp/dfk.txt | mailx -s “File system full alert” bp_hostsupport@satyam.com,dba_ora_offshore@satyam.com

#cat /tmp/dfk.txt

else

exit

fi

Note: the above script will check for mount point space and will send an alert if the used space is > 97%

Posted in Administration, Scripts | Tagged: , , , , | Leave a Comment »

 
%d bloggers like this: