Skip to content

Instantly share code, notes, and snippets.

@technopagan
Created December 14, 2012 16:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save technopagan/4286696 to your computer and use it in GitHub Desktop.
Save technopagan/4286696 to your computer and use it in GitHub Desktop.
###############################################################################
## Basic Configuration
###############################################################################
# Start Monit as background daemon and delay 1st check (in seconds) after boot
set daemon 60
with start delay 120
# Mail configuration
set mailserver localhost
set alert yourname@youremail.tld only on { timeout, nonexist }
###############################################################################
## Monitor Services
###############################################################################
# NGINX
check process nginx with pidfile /var/run/nginx.pid
group webserver
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if failed host localhost port 8080 protocol http
and request "/humans.txt"
then restart
if 3 restarts within 5 cycles then alert
# PHP5-FPM
check process php5-fpm with pidfile /var/run/php5-fpm.pid
group webserver
start program = "/etc/init.d/php5-fpm start"
stop program = "/etc/init.d/php5-fpm stop"
if failed host localhost port 8080 protocol http
and request '/ping'
with timeout 30 seconds for 5 cycles
then restart
if 3 restarts within 5 cycles then alert
depends on nginx
# Varnish
check process varnish with pidfile /var/run/varnishd.pid
group webserver
start program = "/etc/init.d/varnish start"
stop program = "/etc/init.d/varnish stop"
if failed host localhost port 80 protocol http
and request "/"
then restart
if 3 restarts within 5 cycles then alert
depends on nginx
depends on php5-fpm
# Configuration for PHP-FPM service monitoring at /ping
location /ping {
access_log off;
allow 127.0.0.1; # localhost
allow ::1; # IPv6 localhost
deny all;
fastcgi_split_path_info ^(.+.php)(.*)$;
fastcgi_pass unix:/var/run/php-fpm.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment