Monit is the great tool for this purpose as it checks your services periodically and restarts them in case of any troubles. It is a small open source utility for managing and monitoring Unix systems.

This tutorial will cover the most basic setup and configurations to increase the uptime of your applications in case of catastrophic failures.

Install Monit

$ sudo apt-get install monit

Enable Web Interface

Monit comes with it’s own web server to view services and processes status. By default, it is not enabled. To enable it, open the monitrc file which is used to configure “how to control Monit”.

$ sudo nano /etc/monit/monitrc

Keep all the settings as it is and add following code at the bottom of this file just after include /etc/monit/conf.d/* line.

set httpd port 2812 and use address localhost
allow 0.0.0.0/0.0.0.0 # allow localhost to connect to the server
allow admin:monit # require user 'admin' with password 'monit'

As per above configuration, monit will start on port 2812 (generally) and accessible from localhost. But you are free to use any available port for this purpose.

Start the Monit

$ sudo service monit start
or
$ sudo monit start all

Note:If you face the error like “monit: Cannot connect to the monit daemon. Did you start it with http support?”

Just restart the monit daemon by running service monit restart command.

Other Useful Commands

$ sudo service monit stop
$ sudo service monit reload

Check the status of running services

$ sudo monit summary
status of running services

Detailed description of each service

$ sudo monit status

Using this command, we can see the detailed description of all running services.

Detailed description

That’s it.

Thanks for the Reading!!

References


At BoTree Technologies, we build web and mobile applications to add value to our client’s business. We align ourselves to ensure that our client benefits the most out of our engagement.

We work in Ruby on RailsPython, Java, React, Android, iOS and RPA as well.

Drop us a line to discuss how can we help take your business to the next level.

We assure, you would hear back from us in less than 8 hours.