Skip to content

Instantly share code, notes, and snippets.

@grammakov
Forked from vkurennov/monit.rc
Created August 7, 2014 12:15
Show Gist options
  • Select an option

  • Save grammakov/875cdfc176ebf5fe1d33 to your computer and use it in GitHub Desktop.

Select an option

Save grammakov/875cdfc176ebf5fe1d33 to your computer and use it in GitHub Desktop.

Revisions

  1. @vkurennov vkurennov revised this gist Aug 4, 2014. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions monit.rc
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,16 @@ check process nginx with pidfile /opt/nginx/logs/nginx.pid
    if failed host 127.0.0.1 port 80 protocol http
    then restart
    if 3 restarts within 5 cycles then timeout

    ### Postgresql ###
    check process postgresql
    with pidfile "/var/run/postgresql/9.3-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% then restart
    if memory usage > 80% for 2 cycles then restart
    if 5 restarts within 5 cycles then timeout

    ### Redis ###
    check process redis-server
  2. @vkurennov vkurennov created this gist Aug 4, 2014.
    50 changes: 50 additions & 0 deletions monit.rc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    ### Nginx ###
    check process nginx with pidfile /opt/nginx/logs/nginx.pid
    start program = "/etc/init.d/nginx start"
    stop program = "/etc/init.d/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
    if failed host 127.0.0.1 port 80 protocol http
    then restart
    if 3 restarts within 5 cycles then timeout

    ### Redis ###
    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"
    if 2 restarts within 3 cycles then timeout
    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/deployer/qna/shared/tmp/pids/sidekiq.pid"
    start program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec sidekiq --index 0 --pidfile /home/deployer/qna/shared/tmp/pids/sidekiq.pid --environment production --logfile /home/deployer/qna/shared/log/sidekiq.log --daemon'"
    stop program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec sidekiqctl stop /home/deployer/qna/shared/tmp/pids/sidekiq.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/deployer/qna/shared/log/production.sphinx.pid"
    start program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec rake RAILS_ENV=production ts:start'"
    stop program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do 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

    ### Thin (private_pub) ###
    check process thin
    with pidfile "/home/deployer/qna/shared/tmp/pids/thin.pid"
    start program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && RAILS_ENV=production /home/deployer/.rvm/bin/rvm default do bundle exec thin -C config/private_pub_thin.yml start'"
    stop program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && RAILS_ENV=production /home/deployer/.rvm/bin/rvm default do bundle exec thin -C config/private_pub_thin.yml stop'"
    if cpu > 80% then restart
    if memory usage > 80% for 2 cycles then restart
    if 3 restarts within 3 cycles then timeout