23.9 C
Texas
angeloma
Senior Writer and partner

Install Monit on Ubuntu 20.04 to monitor the system services

Hello, friends. In this post, you will learn how to install and configure Monit on Ubuntu 20.04. With this tool, you can quickly monitor the services you have on your server. You will also be able to add others that you manually configure.

Introducing to Monit

According to the project website

Monit is a small Open Source utility for managing and monitoring Unix systems. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.

One of the most important features of Monit is that it is quite easy to deploy on supported systems. These include Linux, BSD, and Solaris. So it is compatible with our distribution.

For example, Monit can act if an error situation should occur, e.g.; if sendmail is not running, Monit can start sendmail again automatically or if apache is using too much resources.

- Advertisement -

also, it can monitor the main system resources such as RAM, CPU, and disk space.

So, let’s get started

Install Monit on Ubuntu 20.04

First, connect to your server via SSH and update it

sudo apt update
sudo apt upgrade

Monit is present in the official Ubuntu repositories so to install it, just run this command:

sudo apt install monit
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  default-mta | postfix | mail-transport-agent sysvinit-core
The following NEW packages will be installed:
  monit
0 upgraded, 1 newly installed, 0 to remove and 24 not upgraded.
Need to get 320 kB of archives.
After this operation, 964 kB of additional disk space will be used.

At the end of the installation, you can check the status of the service

sudo systemctl status monit
● monit.service - LSB: service and resource monitoring daemon
     Loaded: loaded (/etc/init.d/monit; generated)
     Active: active (running) since Tue 2021-08-03 20:27:56 CEST; 31s ago
       Docs: man:systemd-sysv-generator(8)
      Tasks: 1 (limit: 2286)
     Memory: 1.3M
     CGroup: /system.slice/monit.service
             └─1505 /usr/bin/monit -c /etc/monit/monitrc

Aug 03 20:27:56 osradar systemd[1]: Starting LSB: service and resource monitoring daemon...
Aug 03 20:27:56 osradar monit[1494]:  * Starting daemon monitor monit
Aug 03 20:27:56 osradar monit[1494]:    ...done.
Aug 03 20:27:56 osradar systemd[1]: Started LSB: service and resource monitoring daemon.

So, Monit is running fine.

Enabling the web interface

To make monitoring more convenient for you, enable the web interface of the program.

To do this, edit the Monit config file /etc/monit/monitrc.

First, make a backup of it:

sudo cp /etc/monit/monitrc /etc/monit/monitrc.bak

Now edit it using nano.

sudo nano /etc/monit/monitrc

note the lines starting with set httpd port 2812 and and allow admin:monit which are commented out and uncomment them

set httpd port 2812 and
allow admin:password

You can assign any password you want after admin: save the changes and close the editor.

You can check the syntax of the file for any errors.

sudo monit -t

And to apply the changes, restart monit.

sudo systemctl restart monit

Now open your web browser and go to http://your-server:2812 and after entering the password you will see the following.

1.- Monit on Ubuntu 20.04
1.- Monit on Ubuntu 20.04

And you can check the Monit runtime.

2.- Monit Runtime
2.- Monit Runtime

Enabling services to monitor

By default, Monit has several service configurations that you can monitor. They are located in the /etc/monit/conf-available/ directory.

ls /etc/monit/conf-available/`
acpid apache2 at cron mdadm memcached mysql nginx openntpd openssh-server pdns-recursor postfix rsyslog smartmontools snmpd

To enable one, it is only necessary to make a symbolic link to the /etc/monit/conf-enabled/ folder, in the case of Apache, this would be

sudo ln -s /etc/monit/conf-available/apache2 /etc/monit/conf-enabled/`

And apply the changes by restarting Monit

sudo systemctl restart monit

So, enjoy it

Conclusion

Monit helps us to monitor the most critical services of the system from a comfortable graphical interface and with a very simple installation.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article