Article

Table of Contents
Theme:
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles!

Install and Configure Monit on Ubuntu 20.04

Author: Thomas Rakwach

Last Updated: Tue, Aug 3, 2021
System Admin Ubuntu

Introduction

Monit is an open-source utility program used to manage and monitor resources and services on Linux systems. Some services and resources managed by Monit are CPU usage, memory usage, server uptime, network connections, and server applications services. It also makes sure that all running services are always healthy by restarting services that stop or encounter errors during operation. These errors and other important events can be automated to send notifications with certain instances or occurrences. In this article, you will learn how to install and configure Monit on Ubuntu 20.04.

Prerequisites

1. Install and Configure Monit

Install Monit.

$ sudo apt install monit -y

Enable Monit service to run on system boot automatically.

$ sudo systemctl enable monit

Check the status of Monit.

$ sudo systemctl status monit

Enable Monit web interface by editing the default configuration file /etc/monit/monitrc.

$ sudo nano /etc/monit/monitrc

Find the below lines.

# set httpd port 2812 and
# allow admin:monit

Uncomment them and modify the admin password monit with your own. Save and close the file.

set httpd port 2812 and
allow admin:StrongPassword

Test the if the configuration file has no errors.

sudo monit -t

Restart the Monit service to apply the changes.

$ sudo systemctl restart monit

Allow Monit port service in the firewall.

$ sudo ufw allow 2812

Go to your web browser and access the Monit web interface via http://serverIP:2812. For example:

http://192.0.2.11:2812

You will be prompted to log in. Use admin as the username and StrongPassword as the password. Modify password with the actual value you set during configuration.

2. Monitor Services

Monit restarts any services that stop by continuously monitoring all services in your system that have monitoring enabled. To enable monitoring of a service, first install the service, then create a symbolic link of available service configurations to /etc/monit/conf-enabled/. An example using nginx:

$ sudo ln -s /etc/monit/conf-available/nginx /etc/monit/conf-enabled/

Restart the Monit service to apply the changes.

$ sudo systemctl restart monit

Check the status of the added services.

$ sudo monit summary

Conclusion

You have successfully installed and configure Monit on Ubuntu 20.04. You can now install more services and add them to be monitored.

More Information

For more information on Monit, please see the official documentation.

Want to contribute?

You could earn up to $600 by adding new articles