How to Install the Monit Monitoring Tool on CentOS
monit is a utility for managing and monitoring a host of functions of Unix systems, including monitoring processes, programs, files, directories, filesystems and more. I found setting up monit to be pretty straightforward, and it gave me the ability to see what was happening in various corners of my server. Most notably, after setting up monit, I was able to access all of this information via a simple web interface, enabling me to keep an eye on my environment from anywhere (including from my smartphone, using my phone's browser).
DIFFICULTY | Basic - 1 | Medium - 2 | Advanced - 3 |
TIME REQUIRED | 10 min |
RELATED PRODUCTS | CentOS-based VPS or dedicated servers |
RECIPE
Here is a quick tutorial on how to install Monit on CentOS 6.5.
Install Monit
rpm -ivh epel-release-6-8.noarch.rpm
yum install monit
Enable Monit's Web interface
nano monit.conf
Scroll down and uncomment and update these lines
use address xxx.xxx.xxx.xxx # only accept connection from localhost, replace x's with your ip address
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
allow @monit # allow users of group 'monit' to connect
allow @users readonly # allow users of group 'users' to connect readonly
Save the configuration file and exit.
Now, start Monit by entering:
The system should return
Verify and test your configuration
Bring up a web browser and go to http://your server's URL or IP address:2812
You can log in to the monitoring screen with the username and password you set in the configuration file above.
Monitoring particular processes
You can also monitor particular processes using Monit such as Apache and MySQL. Here is how you can enable monitoring of Apache.
nano monit.conf
Scroll down and uncomment and update these lines in the configuration file
start program = "/etc/init.d/apache2 start" with timeout 60 seconds
stop program = "/etc/init.d/apache2 stop"
Restart Monit
You can now check the status of the service using http://your server's URL or IP address:2812
Note: As a courtesy, we provide information about how to use certain third-party products, but we do not endorse or directly support third-party products and we are not responsible for the functions or reliability of such products. Third-party marks and logos are registered trademarks of their respective owners. All rights reserved.