Monitor Apache using monit

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.

Installing monit on CentOS 7


yum install epel-release -y
yum install monit -y

Once installed, save the following in /etc/monit.d/apache


check process httpd with pidfile /var/run/httpd/httpd.pid
group apache
start program = "systemctl start apache"
stop program = "systemctl stop apache"
if failed host 127.0.0.1 port 80 protocol http
with timeout 15 seconds
then restart
if 5 restarts within 5 cycles then timeout

Notes:

  1. Adjust httpd.pid if your apache’s pid is in a different location. On a default installation it might be at /var/run/httpd.pid

Start monit


# Checks for syntax errors
monit -t  
monit 

There are advanced settings which can be adjusted by modifying the file /etc/monitrc such as email notification etc.

How To Add SPF And DomainKeys on cPanel Servers

This code snippet is the simplest way to add SPF and DomainKeys on a cPanel server for all the accounts

[bash]
for i in $(ls /var/cpanel/users)
do
echo Installing Domain Keys on $i
/usr/local/cpanel/bin/domain_keys_installer $i;
echo Installing SPF Records on $i
/usr/local/cpanel/bin/spf_installer $i;
done
[/bash]