In this tutorial we’ll learn how to install Monit on CentOS 7. We will also install and configure its prerequisites. Monit is an opensource monitoring tool for Linux operating system which helps you to monitor services like as HTTPD, MySQL etc. Monit can start a process if it does not run, restart a process if it does not respond and stop a process if it uses too much resources. The monit also has user friendly web interface where you can directly view the system status and setup up processes using native HTTP(S) web server or via the command line interface.
I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an CentOS 7 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.
Install Monit on CentOS 7
Step 1. First, ensure your system is fully up-to-date by running the following:
yum -y update
Step 2. Installing Monit.
First, add EPEL repo to download the latest Monit package:
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm rpm -ivh epel-release-7-8.noarch.rpm
Install Monit using the following command:
yum -y install monit
Start and Enable Monit at system boot by using the following command:
systemctl enable monit sytemctl start monit
Step 3. Configure Monit.
Now we are going to enable monit web interface by configuring the monit conf file:
By default monit is set to check the services at interval of 1 min, this setting can be altered by changing:
## Start Monit in the background (run as a daemon): # set daemon 60 # check services at 30 seconds intervals
To configure the web interface, find and uncomment the following lines:
set httpd port 2812 use address server_ip # only accept connection from localhost allow 0.0.0.0/0.0.0.0 # allow localhost to connect to the server and allow admin:monit # require user 'admin' with password 'monit'
Once you finish the configuration, restart the monit using the following command:
Step 4. Access the Web Interface Monit.
To access the Monit web interface, open the browser, go to the ip of the server http://ip.address:2812 and enter your credentials that you configured before.
Congratulation’s! You have successfully install and configured Monit on your CentOS 7 server. Thanks for using this tutorial for installing monit on CentOS 7 system.