Disk Utilization Email alert -vicidia linux
Topic: How to enable Email alert on disk space outage
Overview:
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% utilization
Step 1: Create a bash script file
Create a bash script file using vi edit as shown below
vi /usr/share/diskspacealert.sh
note: i created a file in /usr/share folder, change according to your requirement
Step 2 : Bash Script
Copy past the below script in the file created in step 1
#!/bin/sh# refered https://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html# enter your mailed below for email alertADMIN="admin123@gmail.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 admin123@gmail.com to your mail id to which you want email alert
Step 3 : make the script executable
Use chmod command and provide read,execute permission for all users
copy paste the below command
chmod 755 /usr/share/diskspacealert.sh
Step 4 : scheduling the scrip to run every day
Setup a cronjob daily morning or whatever time you wish.
type crontab -e in the linux shell
then add the below line
0 10 * * * /usr/share/diskspacealert.sh
this will run the script every day 10 am
Note : ***
you must have installed and configured
Sendmail
postfix
mailx