Install Monit on Raspberry Pi

Monit is an open-source process monitoring tool. This tool allows to manage and monitor system processes such as Apache, MySQL, SSHD, and so on. If process stopped to run, Monit can start it again. Monit can also be used for monitoring files, directories, filesystems, network connections, and system resources. This tool provides web interface to view the status of processes or start, stop and restart them.

This tutorial explains how to install Monit on Raspberry Pi.

Install Monit

Use SSH to connect to Raspberry Pi. Execute the following commands to update the package lists and install Monit:

sudo apt update
sudo apt install -y monit

We can check Monit version:

monit -V

We can use the following command to check whether Monit service is running:

sudo service monit status

We can also stop, start and restart the Monit service:

sudo service monit stop
sudo service monit start
sudo service monit restart

By default web interface is not enabled. To enable it open the main configuration file of Monit:

sudo nano /etc/monit/monitrc

Find and uncomment the following lines:

set httpd port 2812 and
    allow admin:monit      # require user 'admin' with password 'monit'

You can change username and password. Once configured, restart Monit service to apply changes:

sudo service monit restart

Testing Monit

Monit has been installed and we can start to monitor processes. For testing purpose, we will configure to monitor SSHD process that listens incoming SSH connections.

First we need to create the configuration file. It can be placed in the following directories:

  • /etc/monit/conf.d
  • /etc/monit/conf-available

The second option is preferred because configuration can be enabled or disabled when needed.

sudo nano /etc/monit/conf-available/sshd

Add the following content to a file:


check process sshd with pidfile /var/run/
    start program  "/etc/init.d/sshd start"
    stop program  "/etc/init.d/sshd stop"
    if failed port 22 protocol ssh then restart
    if 5 restarts with 5 cycles then timeout

Create a symbolic link to enable configuration:

sudo ln -s /etc/monit/conf-available/sshd /etc/monit/conf-enabled/

Configuration can be disabled as follows:

sudo rm /etc/monit/conf-enabled/sshd

Restart Monit service:

sudo service monit restart

Now check IP address of the Raspberry Pi:

hostname -I

Open a web browser and access Monit web interface with http://<IP_ADDRESS>:2812. The <IP_ADDRESS> is IP address of Raspberry Pi. You should see the SSHD process on the web interface.

SSHD process monitoring using Monit on Raspberry Pi

Uninstall Monit

If you wish to completely remove Monit and related dependencies, run the following command:

sudo apt purge --autoremove -y monit

We can also remove configuration files:

sudo rm -rf /etc/monit

Leave a Comment

Your email address will not be published. Required fields are marked *