Normally our server disk space will be increase at the same time we are not monitoring periodically, we know what will happen if the disk space is full. So create a shell script and send alert to you.
Create a shell file diskreport.sh and give execute permission,
# cd /root
# vim diskreport.sh
# chmod +x diskreport.sh
# vim diskreport.sh
# chmod +x diskreport.sh
copy the following line to shell file,
#!/bin/sh
df -HlP | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 95 ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
mail -s "Alert: Almost out of disk space $usep%" xyz@domain.com abc@domain.com
fi
done
Set Cronjob:
Set cronjob on everyday for example morning 1.00 AM, Edit a cronjob file and add a line,
# crontab -e
00 1 * * * /bin/sh /root/diskreport.sh
Finally, restart cron service,
# /etc/init.d/crond restart
thank you so much, its working fine even on NFS and other type of disk
Thanks Hany...
Thanks Hany its works as expected.