How to Email alert on disk space outage
How to enable Email alert on disk space outage - If you are running servers like vicidial where the disk outage is a major issue while doing recordings which causes serious issue like DB crash , then this article is for your. where you will be get email alert once disk size reaches 80% or any value you set.
Vicidial vs Disk full issue
Most of times you will be facing MySQL database crash error due to my hard disk out of space , Because of huge call Recordings in vicidial or goautodial server.
so i decided to have a alert via email when my harddisk space reaches 90% .
Below is the script i used to get email alert when my hard disk reaches 90% full
thanks to : https://www.cyberciti.biz/
Steps: Email alert once disk reaches 90% utilizationStep 1: Create a bash script file
#!/bin/sh# refered https://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html# enter your mailed below for email alertADMIN="email@example.com"# set alert level 90% is defaultALERT=90df -HP | grep -vE '^Filesystem|tmpfs|cdrom' |while read partition size used free perc mnt ;dousep=$(echo $perc | tr -d '%' )if [ $usep -ge $ALERT ]; thenecho "Running out of space \"$partition ($usep%)\" on $(hostname) ason $(date)" |mail -s "Alert: Almost out of disk space - $usep%" $ADMINfidone
Note *** change the firstname.lastname@example.org to your mail id to which you want email alertStep 3 : make the script executable
Step 4 : scheduling the scrip to run every daychmod 755 /usr/share/diskspacealert.sh
Setup a cronjob daily morning or whatever time you wish.
type crontab -e in the linux shell
0 10 * * * /usr/share/diskspacealert.sh
Note : ***
you must have installed and configured
Email alert when hard disk is full in linux