Alert mail for low disk space
Few months ago I wrote a script that mail to admin for low disk space Shell script to monitor or watch the disk space but now here we improved the script in few better steps.
#!/bin/bash
# Shell script to monitor or watch the low-disk space
# It will send an email to $ADMIN, if the (free avilable) percentage
# of space is >= 90%
# ————————————————————————-
# Linux shell script to watch disk space (should work on other UNIX oses )
# SEE URL: http://www.indiangnu.org
# set admin email so that you can get email
# set alert level 90% is default
PATHS=”/”
AWK=/bin/awk
DU=”/usr/bin/du -ks”
GREP=/bin/grep
DF=”/bin/df -k”
TR=/usr/bin/tr
SED=/bin/sed
CAT=/bin/cat
MAILFILE=/tmp/mailviews$$
MAILER=/bin/mail
mailto=”ravi@indianGNU.org”
for path in $PATHS
do
DISK_AVAIL=`$DF $path | $GREP -v “Filesystem” | $AWK ‘{print $5}’|$SED ‘s/%//g’`
if [ $DISK_AVAIL -gt 90 ];then
echo “Please clean up your stuff \n\n” > $MAILFILE
$CAT $MAILFILE | $MAILER -s “Clean up stuff” $mailto
fi
done
Thanks
Similar Posts:
- Script for checking CPULOAD and send email to admin
- Shell script to monitor or watch the disk space
- Shell script to monitor running services such as web/http, ssh, mail etc.
- How to smarthost on linux using sendmail
- python script for sending mail.
- Create Users And Change Passwords With A Bash Script
- How to schedule job in Linux/Unix – cron , crontab
2 Replies to “Alert mail for low disk space”
It is usefull for Servers.
Thanks…………….
Thanks Ashish,
You find more useful scripts for servers in future.