We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
[HowTo] Monitor Services with Monit on CentOS 7
[HowTo] Monitor Services with Monit on CentOS 7
Introduction
Monit is a free open source utility for managing and monitoring, processes, programs, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations, for example, Monit can prevent your services from getting stopped.
Below are some of the main benefits of using Monit:
For installing Monit you need to add the EPEL repository first:
After that you can install Monit easily using:
After the installation process is finished, you can execute the following commands to start Monit service and make it run at startup:
You can check your Monit service status with the command below:
You can set your preferred Email address to get alerts and reports from Monit with the following command:
Initial Configuration
For doing some configuration you need to open your Monit global configuration file with the command below:
Enable the web interface
In the Monit global configuration file, scroll down to the following block:
By default, Monit only listens on “localhost” and only answers to “localhost” as well, So if you want to be able to connect to your Monit interface from anywhere, you have to comment the following lines:
Make sure to change your username and password to something strong like below:
Now you can visit your Monit web interface at the following address:
Configuring Programs Self-Monitoring
Now it’s time to set some services and processes to be monitored by Monit. You can scroll down the “monitrc” file to see the examples of configurations, but all of them are commented, so leave them be and add your own configurations at the very end of the file. in this section, we are going to configure Monit to prevent your services from being stopped. (Make sure to change the red parts with your own values, the “pid” files locations for each software could be different)
Apache
MySQL
Nginx
After making changes check the syntax of your configuration file for errors:
You should see the following output:
Then restart the Monit service to take effect and start working:
You can check out Monit official website for more information and news!
Monit is a free open source utility for managing and monitoring, processes, programs, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations, for example, Monit can prevent your services from getting stopped.
Below are some of the main benefits of using Monit:
- Automatic process maintenance in a lightweight package.
- Capability to act on out-of-bounds values for CPU, RAM, disk, file size, age and more.
- Monitoring of running services, and the ability to start, kill or restart.
- Automatic email alerts sent at event triggers.
- Web interface for status monitoring.
For installing Monit you need to add the EPEL repository first:
Code: Select all
yum install epel-release
Code: Select all
yum install monit
Code: Select all
systemctl start monit
systemctl enable monit
Code: Select all
systemctl status monit
Code: Select all
set mailserver mail.example.com port 25
set alert [email protected]
For doing some configuration you need to open your Monit global configuration file with the command below:
Code: Select all
nano /etc/monitrc
In the Monit global configuration file, scroll down to the following block:
Code: Select all
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'
Code: Select all
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'
Code: Select all
set httpd port 2812 and
#use address localhost # only accept connection from localhost
#allow localhost # allow localhost to connect to the server and
allow MonitAdmin:5PbTLadz # require user 'MonitAdmin' with password '5PbTLadz'
Code: Select all
http://IP_OR_DOMAIN:2812
Now it’s time to set some services and processes to be monitored by Monit. You can scroll down the “monitrc” file to see the examples of configurations, but all of them are commented, so leave them be and add your own configurations at the very end of the file. in this section, we are going to configure Monit to prevent your services from being stopped. (Make sure to change the red parts with your own values, the “pid” files locations for each software could be different)
Apache
Code: Select all
check process apache with pidfile /run/httpd.pid
start program = "/etc/init.d/httpd start" with timeout 60 seconds
stop program = "/etc/init.d/httpd stop"
Code: Select all
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
Code: Select all
check process nginx with pidfile /var/run/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
Code: Select all
monit -t
Code: Select all
Control file syntax OK
Code: Select all
systemctl restart monit
monit start all
You can check out Monit official website for more information and news!