Monit is a powerful tool for making sure your server is running smoothly. Common uses for Monit are automatically restarting your services like nginx, Apache, SSH, MySQL and more. Monit can also be used for checking folder sizes and displaying them in the web interface (learn how).
This guide will show you how to monitor the size of your root file system with Monit and email you if it exceeds a certain percentage. If you want to get mail alerts from Monit, consider using Mailgun to send the alerts (how to). If you need to install Monit on Ubuntu or Debian you can follow this guide.
Check VPS or Dedicated Server Space + Email Alert with Monit
Create the Monit configuration for checking the space on your hard drive.
sudo nano /etc/monit/conf.d/space
Paste this very simple
check device system with path / if SPACE usage > 80% then alert
Ctrl+X, Y ane Enter to Save and Exit.
Test Monit syntax is valid with our new addition of disk space checking and alerting.
sudo monit -t
Reload Monit if there were no errors
sudo service monit reload
In the Monit interface under Filesystem you can see the space usage displayed live.