Checking free space on a VPS or dedicated server + Email notification from Monit

Monit is a powerful system monitoring tool to keep your server running smoothly. Monit usually automatically restarts its services like Nginx, Apache, SSH, MySQL and more. Monit can also be used to check folder sizes and display them in the web interface.

This tutorial will show you how to control the size of your root filesystem with Monit and e-mail it if it exceeds a certain percentage. If you would like to receive mail notifications from Monit, consider using Mailgun to send notifications. If you need to install Monit on Ubuntu or Debian you can follow this tutorial.

Checking free space on a VPS or dedicated server + Email notification from Monit

Create Monit configuration to check hard disk space.

sudo nano /etc/monit/conf.d/space

Paste this piece of code:

check device system with path /
    if SPACE usage > 80% then alert

Ctrl + X, Y rather than Enter to save and exit.

Monit testing syntax works with our new addition of disk space checking and alert.

sudo monit -t

Update Monit if there were no errors

sudo service monit reload

In the Monit interface, under the file system, you can see the live display of disk space usage.

Sidebar