Monitor Monit Itself

Monit is a fantastic tool for monitoring Unix systems. It is commonly used to monitor daemons and other processes, and allows the user to define recovery and alert actions to carry out programatically when errors occur. However, if Monit itself crashes (or becomes disabled) your services are vulnerable to failure without you knowing about it.

By utilizing one of Monit's buit in features - remote host healthchecks - Cronitor can provide you with a distributed safety check that Monit is running, and that all your services are being properly monitored.

Configuring your Monit heartbeat monitor is a simple 3 step process.

1. Create a new heartbeat monitor with Cronitor

  1. From the Cronitor dashboard create a new monitor selecting the type Heartbeat monitor.
  2. Add a /complete endpoint not pinged in 1 minute rule.
  3. Choose how you would like to be notified (Email, SMS, Slack, etc)

2. Create a new Monit configuration file

Create a new file in /etc/monit/conf.d called monit_monitor.

Nota Bene: It's a common practice is to keep configurations in this directory. However, you need to make sure that your monitrc file - /etc/monit/monitrc - contains the appropriate include statement for this directory

include /etc/monit/conf.d/*

3. Configure Monit to ping your monitor

Add the following to your monit_monitor file.

        check host cronitor with address
          every * * * * *
          if failed
              port 80
              protocol http
              request "/{YOUR_MONITOR_CODE}/complete"
              with timeout 10 seconds
          then exec '' # no-op in the rare case that your request times out.

This tells monit that one of the tasks it needs to perform is to ping{YOUR_MONITOR_CODE}/complete every minute.

If Monit stops running your heartbeat monitor will not receive a ping, and will quickly alert you to the outage!

Side note: Monit's remote healthchecks is a great feature. But, in order to take advantage of this feature you must maintain multiple servers. Cronitor's host healthchecks service provides a distributed alternative. Additionally, our host healthchecks allow the setting of custom http headers, cookies, and validation of response bodies in addition to just HTTP status codes.