Monit configs for VestaCP on Centos7

Last updated on February 6th, 2023 at 01:56 pm.

Monit configs for VestaCP Centos7

Monit  config settings for VestaCP on Centos7.

This short guide will show you how to install (links) Monit on CentOS 7, Ubuntu, Debian etc. This guide also contains Monit configuration settings you can just paste into your Monit config settings file. The guide focuses on VestaCP which is running on a CentOS 7 Server.

 

Related :  Vultr Tutorial – Installing CentOS 7 and Initial Server setup guide for windows users .

 

What is Monit ? :

From the Monit Website :

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.

 

Important Links

The following are important links to help you at any time when you are lost or stuck.

 Install monit

If you haven’t installed monit yet, the following guides will help you install it on centOS 7 , Ubuntu and other Linux Distros.

  1. Linode guide – In the same article, you will cover monit installation on : Arch , CentOS , Debian / Ubuntu, Fedora.
  2. ITzGeek guide – I mostly used this to install on my CentOS 7.
  3. Steven B guide – If you are running Ubuntu this guide will show you how to install Monit on Ubuntu. It also has ready configuration files for you that you will just import into your server to setup Monit Checks.

I was switching back and forth between the first two articles.

 

After configuring the Monit daemon actions, you may feel a bit lost on where to put the config files. That’s the only part this article wants to cover.  This is for you if you are using | VestaCP on Centos7. You will also get ready config settings for VestaCP processes such as Nginx, Apache, MariaDB and other processes listed further down below.

Once you have successfully installed monit. Successfully set up the daemon frequency, server port, email and other settings, you may come back here to get the steps if you are using VestaCP on  Centos 7.

 

Something about Using Monit  Web Interface

After installing Monit, you may want to use the web Interface. To access it you need to go to http://your.ip.address:2812  eg  http://127.0.0.1:2812 .

If you have a firewall installed on your server, you will need to enable port 2812 for it to be accessible on your browser. On VestaCP how to enable the port is shown below.

 

Enable a port on VestaCP (Enable port 2812)

Step 1: Log into your VestaCP

Step 2 : Click on Firewall

Step 3: Click on the Green + button. When you hover on it, you will see the button become add rule.

Step 4 : Adding the rule : Use the following as your rule settings . Then click Add .

 

Action : ACCEPT

Protocol : TCP

Port : 2812

IP address : 0.0.0.0/0

Comment (optional) :  MONIT

 

Here’s an image screenshot with the Vesta Firewall settings :

Add new firewall rule in VestaCP

 

Monitor VestaCP processes

If you are running VestaCP as your panel and you have installed Monit to monitor your server processes, the following are the configs for monitoring and restarting various Vesta Panel processes on CentOS7.

 

Add the configurations just before the includes section as shown in the screenshot below.

 

Monit configs for VestaCP Centos7 - Monitor VestaCP processes

 

The configs to Add

These Monit configs will monitor and restart upon failure,  the following  processes for VestaCP.

  • httpd
  • nginx
  • vesta-nginx
  • vesta-php
  • exim
  • crond
  • vsftpd
  • sshd
  • mariadb
  • monit

 

After you ssh into your Centos server. Edit the Monit configuration file (/etc/monitrc). In this file you will add all the configuration files shown below.

First open the file :

sudo nano /etc/monitrc

Just paste the following before the includes section:

check process httpd with pidfile /var/run/httpd/httpd.pid
  start program = "/usr/bin/systemctl start httpd"
  stop program = "/usr/bin/systemctl stop httpd"

check process nginx with pidfile /var/run/nginx.pid
  start program = "/usr/bin/systemctl start nginx"
  stop program = "/usr/bin/systemctl stop nginx"

check process vesta-nginx with pidfile /var/run/vesta-nginx.pid
  start program = "/usr/bin/systemctl start vesta"
  stop program = "/usr/bin/systemctl stop vesta"

check process vesta-php with pidfile /var/run/vesta-php.pid
  start program = "/usr/bin/systemctl start vesta"
  stop program = "/usr/bin/systemctl stop vesta"

check process exim with pidfile /var/run/exim.pid
  start program "/usr/bin/systemctl start exim"
  stop program "/usr/bin/systemctl stop exim"

check process crond with pidfile /var/run/crond.pid
  start program = "/usr/bin/systemctl start crond"
  stop program = "/usr/bin/systemctl stop crond"

#set logging file as monit.log
set logfile /var/log/monit.log

 

Tip :  In nano, press CTRL V to go to the next page or CTRL Y to go to previous page instead of pressing up and down arrow keys which only go one line at a time.

Right click your mouse or mousepad to paste into nano editor.

 

 

Related :  Vultr Tutorial – Installing CentOS 7 and Initial Server setup guide for windows users .

 

Comment Here

Need WordPress help? Linux Server help? Talk to us.

  • We are your own WordPress customer service.
  • We set up Linux servers and install or migrate WordPress. Learn more here.
  • We support WooCommerce too.
  • Check out our WordPress customer support plans here or contact us below .

If you have any questions regarding WordPress support, Linux server support or any of our services, feel free to reach out or read more on our services page.

Join this free course:

How to host multiple WordPress
websites on a VPS

Close me!