In the next article we are going to take a look at Monit. This tool will be useful when it comes to monitor and manage distributed computing systems, perform automatic maintenance and repairs.
Monit is a utility for manage and monitor processes, programs, files, directories, and file systems on a Unix system. Users can use Monit to monitor files, directories, and file systems for changes, such as timestamp changes, checksum changes, or size changes.
Monit is controlled via an easy-to-configure control file based on a free-form token-oriented syntax. It monitors the logs, and will notify us of the error conditions through customizable alert messages. Additionally, Monit can perform various TCP / IP network checks, protocol checks, and will allow us to use SSL for such checks.
What can be monitored with Monit?
We can use Monit to monitor processes daemon or similar programs running on localhost. This program is particularly useful for monitoring both daemon processes and those that start at system boot time.
Unlike many other monitoring systems, Monit can act if an error situation occurs, for example; if sendmail is not running, this program can start sendmail again automatically or if apache is using too many resources, Monit can stop or restart apache and send us an alert message. Monit can also monitor process characteristics, such as how much memory or CPU cycles a process is using.
In addition to what is mentioned so far, also you can use this program to monitor files, directories and file systems on localhost. We will be able to monitor these elements for changes, such as changes in timestamps, changes in the checksum or changes in size.
Monit can monitor network connections to multiple servers, either on localhost or on remote hosts. TCP, UDP, and Unix domain sockets are supported. Even if a protocol is not supported, we will be able to test the server because Monit can be configured to send any data and test the response from the server.
Monit can be used to test programs or scripts at certain times as with cron. In addition, it will allow us to test the output value of a program and perform an action or send an alert if the output value indicates an error.
This program can also be used to monitor general system resources on localhostsuch as overall CPU usage, memory, and system load.
Install Monit on Ubuntu 20.04 LTS Focal Fossa
The installation of this program is quite simple. In the following lines we are going to see how to install Monit in Ubuntu 20.04. As indicated on their website, the same instructions can be followed for Ubuntu 18.04, 16.04 and any other Debian-based distribution such as Linux Mint.
To start, let's open a terminal (Ctrl + Alt + T) and we are going to make sure that all the packages in our system are updated. We will achieve this with the commands:
sudo apt update; sudo apt upgrade
Then we can install the program. Monit is available the default Ubuntu 20.04 repository. For this reason, we can install it using the command in the terminal:
sudo apt install monit
Once installed, the Monit service will start automatically. It can check its status typing in the same terminal:
sudo systemctl status monit
By default, the Monit web interface is disabled. For this reason we will have to enable it and set the administrator password. We can do this by editing the following file:
sudo vim /etc/monit/monitrc
Inside this file we will have to find, uncomment and configure the Monit administrator password as it's shown in the following:
set httpd port 2812 and allow admin:monit
Once the changes are made, we can save and close the editor. The next step will be restart Monit:
sudo monit -t sudo systemctl restart monit
If you need information about any of the options in the configuration file, you can consult the program documentation.
Access the program interface
At this point, we can open the web browser and access the program's web interface by going to the URL http://dirección-ip-de-tu-servidor:2812.
This address should show us the login page. If you have not changed the username and password in the configuration file, you can login with username 'admin' and the password 'monit'.
For helpful information and help, we recommend check the official website of the project or on repository in bitbucket.