Monday, January 12, 2015

Script for Disk Space Alerts on Linux / Unix

[root@deepti .myscripts]# cat diskSpaceAlert.sh
diskSpace=`df`
usedSpace=`echo "$diskSpace" | sed -n '/sysvg-lv_root/{n;p;}' | awk '{print $4}' | cut -f1 -d"%"`

if [ $usedSpace -gt 60 ] ; then
     wall "Disk Space usage is greater than 60%: Actual used space is: $usedSpace%; Free some space immediately."
     echo "Disk Space usage is greater than 60%: Actual used space is: $usedSpace%; Free some space immediately" >> /tmp/diskUsage.txt
fi


No comments:

Post a Comment