Skip to content

Latest commit

 

History

History
55 lines (35 loc) · 1.6 KB

README.md

File metadata and controls

55 lines (35 loc) · 1.6 KB

monit

Note: ONLY WORKS WITH CENTOS AND RHEL

Basic Monit configuration along with a python script used to check the responsiveness of a local application/website.

This uses a combination of monit and python to prevent a continuous loop of restarting the service in the case of an application issue producing a bad error response code


Example Monit Configuration:

Apply the following configuration to /etc/monit.d/filename

check host localhost with address localhost every 2 cycles
   if failed
       port 443 protocol https
       with http headers [Host: test.lazyluke.xyz, Cache-Control: no-cache]
       and request /
    then exec "/home/python/monit_service_check.py"


monit_service_check Python Script

Now use the python script located in this repository as the "exec" part of the monit logic.

Replace

Replace Part 1 )

The python script will attempt to write to /var/log/monit/service.log. Find and replace all instance of this path in the file (EXCEPT open("/var/log/messages")) with a filename of your choosing and make sure the directory and file exist.


Replace Part 2 )

The python script runs a bash curl command (yes, its not ideal to run a bash command).

Replace https://localhost -H 'Host: test.lazyluke.xyz' in the following curl command in the python script with the application/website you wish to monitor

curl_response = subprocess.call(["curl --output /dev/null --silent --head --fail -k --connect-timeout 30 https://localhost -H 'Host: test.lazyluke.xyz'"], shell=True)