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. Monit has built-in a lightweight HTTP(S) interface you can use to browse the Monit server and check the status of all monitored services. From the web interface, you can start, stop and restart processes and disable or enable monitoring of services.
In this guide, we will install Monit and configure it for us to monitor host resources via the Monit web interface.
Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your own cloud servers.
Updating System Packages
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:
sudo yum update
Step 1: Install Monit using the YUM command
Issue the command below to download and install Monit using the YUM command from the EPEL Repo.
sudo yum install -y monit
Step 2: Start Monit Daemon
After installing Monit, issue the command below to start the Monit daemon.
Step 3: Check Monit Status
Now that we have successfully started the Monit daemon without any issues, you can view the status of the daemon by issuing the command below.
From the screenshot above, we can see that it shows us the Status, Monitoring Status, Monitoring Mode, Load Average, CPU, Memory Usage, Swap Usage, Uptime, On-Reboot, Boot Time, and Data Collected right there on the terminal.
The main configuration file for Monit is the
/etc/monitrc file. You can make a few changes to this configuration file for your requirement.
By default, the Monit daemon is set to check the services at an interval of 30 seconds as shown in the screenshot below. This setting can be modified by changing the value on the line below:
set daemon 30
Monit Web Interface
Monit provides a web interface for monitoring and managing the configured services. Monit listens on port 2812 by default but we need to configure this by editing the
/etc/monitrc configuration file
sudo nano /etc/monitrc
set httpd port 2812 use address 126.96.36.1999 #replace 188.8.131.529 with your server's IP allow 0.0.0.0/0.0.0.0 allow admin:monit
Ensure to save the file before closing.
Note, the username is admin and the password is monit. You can change this as you wish. You can also change the port number to a number of your choice.
Next, proceed to reload monit by issuing the command below:
sudo systemctl restart monit
Next, enable Monit to start-up automatically on boot with the command below:
sudo systemctl enable monit
Note: If you use CSF firewall, ensure that you add the port 2812 to the incoming and outgoing TCP connections.
Next, visit your domain or server IP on port 2812. In this guide, we are visiting
cloudwaferlabs.com.ng:2812 as shown below. You will be prompted to enter the username and password mentioned earlier.
You can read more on the Monit Documentation here
You can also check out the guide on Installing Nagios on CentOS here