Step by Step Guide to install Monit Monitoring tool on ubuntu 20.04 LTS

Monit is a free & open source service monitoring tool.It is a command line utility.It is used to manage & monitor filesystems, directories, files, programs, and processes.It is also used to monitor CPU, RAM, Disk & File Size.Monit provides a web interface to control & monitor the state of application process.

There are few steps to install & configure Monit on ubuntu:

Step 1: Update the System.

apt-get update

Step 2: Install the monit on system.

apt-get install monit

  • Check the monit version.

monit -V

  • Here is the command output.

Step 3: Start & Enable the monit.

systemctl start monit
systemctl enable monit

  • Check the monit status.

systemctl status monit

  • Here is the command output.

Step 4: Configure the monit.

  • Open the following file.

vim /etc/monit/monitrc

  • Uncomment & edit the following lines.
  • Provide the username & password for login on monit web interface.

set httpd port 2812 and
allow admin:password_here

  • Here is the command output.

  • To verfiy the monit configuration.

monit -t

  • Here is the command output.

  • Restart the monit.

systemctl restart monit

  • Allow the following port number on UFW firewall.

ufw allow 2812

  • Here is the command output.

Step 5: Access Monit web interface

http://server-ip:2812

  • Here is the output.
  • Provide the username & password.
  • Click on Sign in.

  • Now Monit monitoring server is Ready.

Step 6: To Check the status of Monit.

monit status

  • Here is the command output.

Step 7: To Monitor Apache2 and MariaDB using monit.

  • Install the apache2 & mariadb server.

apt-get install apache2 mariadb-server

  • To enable the Apache and MariaDB monitoring.

ln -s /etc/monit/conf-available/apache2 /etc/monit/conf-enabled/
ln -s /etc/monit/conf-available/mysql /etc/monit/conf-enabled/

  • Restart the monit.

systemctl restart monit

  • To check monitored processes summary.

monit summary

  • Here is the command output.

  • Go to monit web interface,Refresh the page.
  • Here is the output.

Step 8: We have another option to monitor apche2 & mariadb using monit.

  • Create a config file.

vim /etc/monit/conf.d/custom.conf

  • Add the following lines:

# Apache configuration
check process apache2 with pidfile /run/apache2/apache2.pid
start program = "/bin/systemctl start apache2" with timeout 60 seconds
stop program = "/bin/systemctl stop apache2"
# MariaDB configuration
#
check process mariadb with pidfile /run/mysqld/mysqld.pid
start program = "/bin/systemctl start mariadb" with timeout 60 seconds
stop program = "/bin/systemctl stop mariadb"

  • Here is the output.

  • Check the monit configuration.

monit -t

  • Restart/Reload the monit.

systemctl restart monit

  • To check the summary of process list.

monit summary

  • Here is the command output.

  • Go to monit web interface,Refresh the page.
  • Here is the output.

Step 9: Click on any service name to display all details of service.We can start,stop,restart the service & Disable/Enable the monitoring.

Step 10: To check the status of the Apache service.

monit summary apache

Leave a Reply