Skip to content

Instantly share code, notes, and snippets.

@askrynnikov
Last active April 22, 2017 04:57
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 askrynnikov/170efc834b4a0376ae9d71b6b0fe8639 to your computer and use it in GitHub Desktop.
Save askrynnikov/170efc834b4a0376ae9d71b6b0fe8639 to your computer and use it in GitHub Desktop.
Config monit for qna
### Unicorn ###
check process unicorn
with pidfile "/home/deploy/qna/shared/tmp/pids/unicorn.pid"
start program = "/bin/su - deploy -c 'cd /home/deploy/qna/current && RAILS_ENV=production /home/deploy/.rbenv/bin/rbenv exec bundle exec unicorn -c /home/deploy/qna/current/config/unicorn/production.rb -E deployment -D'"
stop program = "/bin/su - deploy -c 'kill -s QUIT `cat /home/deploy/qna/current/tmp/pids/unicorn.pid`'"
if memory usage > 90% for 3 cycles then restart
if cpu usage > 90% for 2 cycles then restart
if 5 restarts within 5 cycles then timeout
### Nginx ###
check process nginx with pidfile /run/nginx.pid
start program = "/usr/sbin/service nginx start"
stop program = "/usr/sbin/service nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
# For the tests commented out!
if 3 restarts within 5 cycles then timeout
### Postgresql ###
check process postgresql
with pidfile "/run/postgresql/9.5-main.pid"
start program = "/usr/sbin/service postgresql start"
stop program = "/usr/sbin/service postgresql stop"
if failed host localhost port 5432 protocol pgsql then restart
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 2 cycles then restart
if 5 restarts within 5 cycles then timeout
### Redis ###
check process redis-server
with pidfile /run/redis/redis.pid
group redis
start program = "/usr/sbin/service redis start"
stop program = "/usr/sbin/service redis stop"
if totalmem > 100 Mb then alert
if children > 255 for 5 cycles then stop
if cpu usage > 95% for 3 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 127.0.0.1 port 6379 then restart
if 5 restarts within 5 cycles then timeout
### Sidekiq ###
check process sidekiq
with pidfile "/home/deploy/qna/shared/tmp/pids/sidekiq-0.pid"
start program = "/bin/su - deploy -c 'cd /home/deploy/qna/current && /home/deploy/.rbenv/bin/rbenv exec bundle exec sidekiq --index 0 --pidfile /home/deploy/qna/shared/tmp/pids/sidekiq-0.pid --environment prod$
stop program = "/bin/su - deploy -c 'cd /home/deploy/qna/current && /home/deploy/.rbenv/bin/rbenv exec bundle exec sidekiqctl stop /home/deploy/qna/shared/tmp/pids/sidekiq-0.pid 10'"
if cpu > 80% then restart
if memory usage > 80% for 2 cycles then restart
if 3 restarts within 3 cycles then timeout
### Sphinx ###
check process sphinx
with pidfile "/home/deploy/qna/shared/tmp/searchd.pid"
start program = "/bin/su - deploy -c 'cd /home/deploy/qna/current && /home/deploy/.rbenv/bin/rbenv exec bundle exec rake RAILS_ENV=production ts:start'"
stop program = "/bin/su - deploy -c 'cd /home/deploy/qna/current && /home/deploy/.rbenv/bin/rbenv exec bundle exec rake RAILS_ENV=production ts:stop'"
if cpu > 80% then restart
if memory usage > 80% for 2 cycles then restart
if 3 restarts within 3 cycles then timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment