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 MariaDB on CentOS 7?

1. Insatll MariaDB on server -  #yum install mariadb-server OR #yum install -y mariadb...

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 get files and folders from a remote server using FTP?

Let's make a quick start by looking at the various commands to get files and folders from a...

How to setup PPTP VPN?

A Point-To-Point Tunneling Protocol (PPTP) allows you to implement your own VPN very quickly, and...

How to install FFMPEG CentOS?

ffmpeg is the most popular opensource video streaming software and its being used on many...

Powered by WHMCompleteSolution