Skip to content

Instantly share code, notes, and snippets.

@jyfcrw
Last active March 21, 2016 02:43
Show Gist options
  • Save jyfcrw/4150795cb59bb30558db to your computer and use it in GitHub Desktop.
Save jyfcrw/4150795cb59bb30558db to your computer and use it in GitHub Desktop.
Monit basic configuration with HTTP/monit status
set daemon 120
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
set eventqueue
basedir /var/lib/monit/events
slots 100
set httpd port 2812 and
allow localhost
include /etc/monit/conf.d/*
check process mosquitto with pidfile /var/run/mosquitto.pid
start program = "/bin/bash -l -c '/usr/local/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d'"
stop program = "/bin/bash -l -c 'kill -TERM $(cat /var/run/mosquitto.pid)'"
check process myproject-sidekiq with pidfile /var/www/default/apps/myproject/shared/tmp/pids/sidekiq.pid
start program = "/bin/bash -l -c 'export PATH=/var/www/.rbenv/shims:/var/www/.rbenv/bin:$PATH && cd /var/www/default/apps/myproject/current/ && bundle exec ./daemons/sidekiq start'" as uid "www-data" and gid "www-data"
stop program = "/bin/bash -l -c 'export PATH=/var/www/.rbenv/shims:/var/www/.rbenv/bin:$PATH && cd /var/www/default/apps/myproject/current/ && bundle exec ./daemons/sidekiq stop'" as uid "www-data" and gid "www-data"
# if totalmem is greater than 500 MB for 2 cycles then restart # VM bloat is common in Rails apps
group myproject
check process nginx with pidfile /var/run/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
check process postgresql-9.3 with pidfile /var/run/postgresql/9.3-main.pid
start program = "/etc/init.d/postgresql start"
stop program = "/etc/init.d/postgresql stop"
if failed unixsocket /var/run/postgresql/.s.PGSQL.5432 protocol pgsql
then restart
if failed host 127.0.0.1 port 5432 protocol pgsql then restart
if 5 restarts within 5 cycles then timeout
check process redis-server with pidfile /var/run/redis/redis-server.pid
start program = "/etc/init.d/redis-server start"
stop program = "/etc/init.d/redis-server stop"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment