']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();

Linux How to..

Linux How to ,Share Knowledge

TAG :  Simple Shell Scripts Monitor Hard Disk on Linux 

Example Solutions :

vim /root/disk_monitor.sh
input line below :

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

#!/bin/sh
# of space is >= 90%
#
ADMIN=”email@domain.com”   # –> Your Email Admin
# alert level 90%
ALERT=90
df -H | grep -vE ‘^Filesystem|tmpfs|cdrom’ | awk ‘{ print $5 ” ” $6 }’ | while read output;
do
#echo $output  #uncomment with debug
usep=$(echo $output | awk ‘{ print $1}’ | cut -d’%’ -f1 )
partition=$(echo $output | awk ‘{ print $2 }’ )
if [ $usep -ge $ALERT ]; then
echo “Running out of space ”$partition ($usep%)” on $(hostname) as on $(date)” |
mail -s “Alert:  Linux Server out of disk space $usep%” $ADMIN
fi
done

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

Run Every 30 Minute on Crontab

#crontab -e

input line below :

#monitor disk
*/30 * * * * /bin/sh /root/disk_monitor.sh >/dev/null 2>&1

save now and Success Solutions

If disk usage over 90% then alert mail to ADMIN Email

Add A Comment