Pavan DBA's Blog

The DBA Knowledge Store

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%

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: