We have moved to www.dataGenX.net, Keep Learning with us.

Tuesday, July 10, 2012

File System Monitoring Script in NIX


Hi Friends,
Here I am come up with second FS monitoring script, this script sent you the list of FS which
Have the FS size more then the THRESHOLD value you defined.




#!/bin/ksh
# This script monitors available disk space.
# This script emails an alert when a locally mounted partition crosses a given threshold.
# Set your threshold percentage (do not include the % sign), email address, and excluded mount points, then add
to crontab
#
# Add this to crontab -e for root
# Diskspace monitoring script
#0 6 * * 1-5 /bin/diskMonitor.sh >/dev/null 2>&1
THRESHOLD="90"
EMAIL="atulsingh@pc.com"
EXCLUDE="/proc|/auto/home|Mounted"
df -m | egrep -v "(${EXCLUDE})" | while read LINE
do
per=`echo $LINE | awk '{print $4}' | tr -d '%' | grep [0-9][0-9]*`
dir=`echo $LINE | awk '{print $NF}'`
if [[ $per -gt $THRESHOLD ]]
then
echo $per%' '$dir
fi
done | mail -s "FS Status on `hostname`" $EMAIL

njoy the simplicity.......
Atul Singh