How to setup the email alert for low disk space?

If you don't want to setup to a full monitoring solution such as Nagios you can create your own scripts for monitoring the disk space. The following script alerts you when the root partition of server is almost full:

---------------------------------
#!/bin/bash
CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=90
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
    mail -s 'Disk Space Alert' test@domain_name.com << EOF
Your root partition remaining free space is critically low. Used: $CURRENT%
EOF
fi
---------------------------------

The script sends an email when the disk usage cross the percentage specified by the THRESHOLD varialbe (90% here).

To run it daily, for example, save the script to the file sample.sh in your home directory, change the email address with your email, and add the following line at the end of /etc/crontab file:

@daily ~/disk_space_alert.sh
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to install AVG Antivirus scanner on Ubuntu?

AVG free is antivirus which protects from spyware as well malware. It is free to use for private...

How to setup a WordPress website on plain Centos server?

The following steps have been successfully tested on a plain centos server. Now lets start...

How to change the port number of Apache Web Server?

Default port to access the Apache is 80. Secure port for communicating with world for Apache is...

How to install Postfix on CentOS?

Postfix is an open-source Mail Transport Agent (MTA), which supports protocols like LDAP, SMTP...

How to install SOAP on CentOS?

Install SOAP on CentOS 1) Fire below command - yum install php-soap Output will be as follow...

Powered by WHMCompleteSolution