Home » Home Server » Monit: Server hard drive storage monitoring (HDD space)

Monit: Server hard drive storage monitoring (HDD space)

Server storage monitoring with Monit allows you to keep a check on your home server or web server storage space. Monit is an automatic monitoring, maintenance, and repair utility for Unix systems. If the resource usage is high Monit will send you an email alert. You can then examine and resolve any issues. In this Monit tutorial, I will describe automatic drive space monitoring with Monit for your home server. By server storage monitoring I mean how full any of your drive partitions are. I am assuming that you have already installed and configured Monit following my previous guide.

Determine the Drive Partitions to Monitor

Before you setup storage monitoring with Monit, you need to know what drives and partitions you want to monitor. If you remember my recently built HTPC-NAS combo, I have two hard drives on my server (sda, which is a SSD and sdb, which is a 4 TB HDD). sda has 3 partitions (sda1, sda2, and sda3). I wanted to monitor only sda1 (root) partition and sda3 (home partition). sdb has only one partition. If you do not know which ones to monitor use the lsblk command. The output will look like what is shown below.

List All Disk Drives with lsblk Command
List All Disk Drives with lsblk Command

So, I wanted to monitor in total 3 partitions (sda1, sda3, and sdb1).

Monitor your home server with Monit:

Server Storage Monitoring with Monit

Next, it is required that you have a working Monit instance with a proper /etc/monit/monitrc file. Monit configurations for various services are loaded from /etc/monit/conf.d folder. For drive space monitoring with Monit, create a Monit configuration file using the following command:

sudo /etc/monit/conf.d/storagespace

Copy the following contents to it, save, and exit (press Ctrl X, press Y, and press ENTER).

# add each drive you want to monitor below
check filesystem Ubuntu with path /dev/sda1
    if space usage > 90% then alert
check filesystem Home with path /dev/sda3
    if space usage > 90% then alert
check filesystem Media with path /dev/sdb1
    if space usage > 90% then alert

The code above code will monitor hard drive space in 3 partitions in 2 drives. If any of them is more than 90% full, I will receive and email alert. An example of Monit alert is shown below.

Monit System Monitoring Email Alert
Monit System Monitoring Email Alert

So, use the lsblk command and customize the code above. You may also customize the partition names (Ubuntu, Home, and Media) and/or set a different fill percentage than 90.

Test and Reload Monit

Once you make any changes you have to test Monit configuration:

sudo monit -t

You should see the following message: Control File Syntax OK. Then, check to see if Monit is already running using the following command:

sudo /etc/init.d/monit status

If Monit is running, reload Monit configurations using the following command:

sudo /etc/init.d/monit reload

If Monit is not running, then start it using sudo monit command instead. The whole sequence of commands for testing and reloading Monit is shown in the picture below.

Monit Test and Reload
Monit Test and Reload

Now, fire up your web browser and visit one of the following URLs depending on how your Monit is configured (be sure to use the correct port number):

  • http://localhost:2812
  • http://IPADDRESS:2812 (local network IP)
  • http://domain.com:2812 (if you have domain name pointing to your server)

You should see the monitored partitions listed with percent fill level as shown in the picture below.

Storage Monitoring with Monit
Monitoring Storage Spaces with Monit

That is it for Storage monitoring with Monit. As you can see Monit allows for automatic drive space monitoring, which can be a big help for system administrators. Monit Wiki page has several examples. More home server specific Monit examples to follow, so keep checking back.

We Are Hiring: Familiar with Media Streaming, HTPC, Home Server, Smart Home, and Home Automation topics? Write about it and earn money. No writing experience needed. APPLY HERE.

Get 20% OFF with IPVanish VPN:

♦   Hide your browsing and streaming activity: No logs and no tracking
♦   Access geo-restricted content from anywhere
♦   Encrypt and anonymize: Kodi, Plex, Downloads, Personal Info
♦   Windows, Mac, Linux, Android, iOS, Router, and more.
♦   Money back guarantee - Sign Up Now

About the author

Anand

Anand is a self-learned computer enthusiast, a part-time blogger, and a Food Scientist by career. He has been blogging since 2010 on Linux, Ubuntu, Home/Media/File Servers, Smart Home Automation, and related HOW-TOs on htpcbeginner.com and smarthomebeginner.com.

Archives

Join the other 110,000 followers