How to monitor the mount point in file system.
Some times requirement came like we have to monitor a specific mount point which is very very important for our project to smoothly run the business flows. Whenever there the usage reached to threshold level, it should alert us so that we could take necessary action on it,like removing files,zipping files or moving files to other mount point so clear the space.
Please find the below script which is doing the similar action
Please Note: Here I am monitoring the mount point /u01 which has 217GB and when the mount point usage will be 210GB (97%) it will send the alert mail to folks mentioned in the EMAIL list.
Example I have created the below script in file Filemonitor.ksh
#!/bin/ksh
THRESHOLD="97"
#hostname- in which server you want to monitor the file system
EMAIL="dekhatai@in.xyz.com"
# Excluded -mount points which we don't required to monitor,if want remove from the EXCLUDE list and it will get monitor
EXCLUDE="/usr|/var|/tmp|/home|/proc|/opt|/admin|/tools|/var/adm/ras/livedump|/u11|/u12|/u13|/u14|/u21|/u22|/u23|/temp|/mksysbimg|/staging|/u02|/u04|/arch"
df -k | awk '{print $7"\t"$4}' |egrep -v "(${EXCLUDE})" | while read LINE; do
PERC=`echo $LINE | awk '{print $2}' | cut -d"%" -f1`
if [ $PERC -gt $THRESHOLD -o $PERC -eq $THRESHOLD ]; then
echo "${PERC}%- Threshold Value Reached to /u01 on`hostname`.thesource.ca .Please Release Space to avoid any batch releated issues." |mail -s "Space Alert: ${LINE}-reached threshold level on `hostname` server" $EMAIL
fi
done
Set the shell script in cron job which will run in every minutes(changes as per your requirement)
* * * * * /staging/debashis/Filemonitor.ksh
Thanks..
Hope it will help you..Enjoy..
Some times requirement came like we have to monitor a specific mount point which is very very important for our project to smoothly run the business flows. Whenever there the usage reached to threshold level, it should alert us so that we could take necessary action on it,like removing files,zipping files or moving files to other mount point so clear the space.
Please find the below script which is doing the similar action
Please Note: Here I am monitoring the mount point /u01 which has 217GB and when the mount point usage will be 210GB (97%) it will send the alert mail to folks mentioned in the EMAIL list.
Example I have created the below script in file Filemonitor.ksh
#!/bin/ksh
THRESHOLD="97"
#hostname- in which server you want to monitor the file system
EMAIL="dekhatai@in.xyz.com"
# Excluded -mount points which we don't required to monitor,if want remove from the EXCLUDE list and it will get monitor
EXCLUDE="/usr|/var|/tmp|/home|/proc|/opt|/admin|/tools|/var/adm/ras/livedump|/u11|/u12|/u13|/u14|/u21|/u22|/u23|/temp|/mksysbimg|/staging|/u02|/u04|/arch"
df -k | awk '{print $7"\t"$4}' |egrep -v "(${EXCLUDE})" | while read LINE; do
PERC=`echo $LINE | awk '{print $2}' | cut -d"%" -f1`
if [ $PERC -gt $THRESHOLD -o $PERC -eq $THRESHOLD ]; then
echo "${PERC}%- Threshold Value Reached to /u01 on`hostname`.thesource.ca .Please Release Space to avoid any batch releated issues." |mail -s "Space Alert: ${LINE}-reached threshold level on `hostname` server" $EMAIL
fi
done
Set the shell script in cron job which will run in every minutes(changes as per your requirement)
* * * * * /staging/debashis/Filemonitor.ksh
Thanks..
Hope it will help you..Enjoy..