CPIT-490/CPIT-632
GitLab
By Fahad AlSayyali & Osama AlSarhani
Monit is a small Open Source utility for managing and monitoring UNIX systems. Monit conducts automatic maintenance, repair, and can execute meaningful causal actions in error situations.
For installing Monit, you need to add the EPEL repository first:
yum install epel-release
After that you can install Monit using:
yum install monit
You can execute the following commands to start Monit service and make it run at startup and reload it:
systemctl start monit systemctl enable monit systemctl restart monit
For starting Monit:
monit
For showing the status:
monit status
(/etc/monitrc) is the main configuration file of Monit. We will make a few changes to the Monit configuration file for our requirement:
nano /etc/monitrc
By default, Monit is set to check the services at an interval of 1 min. This setting can be altered by changing this line:
set daemon 60
In the Monit global configuration file, scroll down to the following block:
set httpd port 2812 and use address localhost # only accept connection from localhost allow localhost # allow localhost to connect to the server allow admin:monit # require user 'admin' with password'monit'
By default, Monit only listens on “localhost” and only answers to “localhost” as well, So if you want to be able to connect to Monit interface from anywhere, you have to comment the following lines:
set httpd port 2812 and #use address localhost # only accept connection from localhost #allow localhost # allow localhost to connect to the server and allow admin:monit # require user 'admin' with password 'monit'
Make sure to change your username and password to something strong and add this extra lines like below:
set httpd port 2812 allow 0.0.0.0/0.0.0.0 allow admin:monit
Now you can visit your Monit web interface at the following address: http://IP_OR_DOMAIN:2812
http://IP_OR_DOMAIN:2812
Configure the firewall to allow access to Monit web interface, running on port 2812.
firewall-cmd --permanent --add-port=2812/tcp firewall-cmd –reload