Skip to content

Instantly share code, notes, and snippets.

@leifcr
Created June 12, 2014 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leifcr/786232e1e7700f146a4e to your computer and use it in GitHub Desktop.
Save leifcr/786232e1e7700f146a4e to your computer and use it in GitHub Desktop.
# /etc/monit/conf.d/avialable/foo_delayed_job_production.conf
#
# Monit configuration for Delayed Job
#
# Delayed job for app foo running as deploy in environment production
#
# Service name: foo_production_delayed_job
#
check process foo_production_delayed_job
# Checking for a pidfile
with pidfile /web/production/foo/shared/runit/delayed_job/supervise/pid
# Command to start the service
start program = "/bin/bash -c '[ ! -h /web/production/foo/shared/runit/delayed_job/run ] || /usr/bin/sv start /web/production/foo/shared/runit/delayed_job'"
# Command to stop the service
stop program = "/usr/bin/sv -w 12 force-stop /web/production/foo/shared/runit/delayed_job"
# Alert and restart thresholds for Mem and CPU
# Delayed job uses about 100 mb for one worker.
if mem is greater than 115.0 MB for 2 cycles then alert
if mem is greater than 150.0 MB for 3 cycles then restart
# The worker can do some intensive background tasks, so allow quite a lot of cpu usage
# But should finish within 4-5 cycles
# Limits for catching hanging processes
if cpu is greater than 90% for 15 cycles then alert
if cpu is greater than 95% for 20 cycles then restart
# Replace mail with real mail
set alert me@domain.com
# Place this in the foo_production group, to make it easier to stop/start all services for given app
group foo_production
# /etc/monit/conf.d/avialable/foo_puma_production.conf
#
# Monit configuration for Puma
#
# Puma for app foo running as deploy in environment production
#
# Service name: foo_production_puma
#
check process foo_production_puma
# Checking for a pidfile
with pidfile /web/production/foo/shared/pids/puma.pid
# Command to start the service
start program = "/bin/bash -c '[ ! -h /web/production/foo/shared/runit/puma/run ] || /usr/bin/sv start /web/production/foo/shared/runit/puma'"
# Command to stop the service
stop program = "/usr/bin/sv -w 12 force-stop /web/production/foo/shared/runit/puma"
# Alert and restart thresholds for Mem and CPU
# Puma uses about 60 mb per worker, and we have 2 workers.
# Total 135 mb should be enough, if not, something is wrong, do alert!
if mem is greater than 150.0 MB for 2 cycles then alert
if mem is greater than 175.0 MB for 3 cycles then restart
if cpu is greater than 90% for 2 cycles then alert
if cpu is greater than 95% for 5 cycles then restart
# Replace mail with real mail
set alert me@domain.com
# Place this in the foo_production group, to make it easier to stop/start all services for given app
group foo_production
# All monit services will start when the system starts
# You can enable/disable service by adding/removing services from:
# /etc/monit/conf.d/enabled
# Enable all services in the group
monit -g foo_production monitor
# Disable monitoring for the group
monit -g foo_production unmonitor
# Starting/stopping/restarting all services in the group
monit -g foo_production start
monit -g foo_production stop
monit -g foo_production restart
# Global commands
monit reload # reloads config
monit status
monit validate
monit summary
# Starting/stopping particular services
# example for foo_production_puma
monit foo_production_puma start
monit foo_production_puma stop
monit foo_production_puma restart
monit foo_production_puma monitor
monit foo_production_puma unmonitor
# Global monit configuration
# /etc/monit/monitrc
#
set daemon 60
with start delay 60
set logfile syslog facility log_daemon
set mailserver localhost
set eventqueue
basedir /var/monit # set the base directory where events will be stored
# slots 1000 # optionaly limit the queue size
set mail-format {
from: monit@$HOST
subject: $SERVICE $EVENT $HOST
message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.
}
set httpd port 2812
use address localhost
allow localhost
signature enable
include /etc/monit/conf.d/enabled/*.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment