Skip to content

Instantly share code, notes, and snippets.

@raecoo
Last active October 26, 2022 06:24
Show Gist options
  • Save raecoo/5001521 to your computer and use it in GitHub Desktop.
Save raecoo/5001521 to your computer and use it in GitHub Desktop.

Revisions

  1. raecoo revised this gist May 1, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion monit-example.txt
    Original file line number Diff line number Diff line change
    @@ -49,4 +49,4 @@ check process sidekiq
    start program = "/bin/sh -c 'cd /var/www/project-name/current; PATH=/usr/local/bin:$PATH RAILS_ENV=production bundle exec sidekiq -C config/sidekiq.yml -P tmp/pids/sidekiq.pid" as uid deploy
    stop program = "/bin/sh -c 'cd /var/www/project-name/current && kill -s INT `cat tmp/pids/sidekiq.pid`'"
    if totalmem is greater than 200 MB for 10 cycles then restart # eating up memory?
    group redis_workers
    group sidekiq_workers
  2. raecoo revised this gist Feb 21, 2013. 1 changed file with 0 additions and 7 deletions.
    7 changes: 0 additions & 7 deletions monit-example.txt
    Original file line number Diff line number Diff line change
    @@ -44,13 +44,6 @@ check process redis
    if 5 restarts within 5 cycles then timeout
    group redis_workers

    check process resque
    with pidfile /var/www/project-name/current/tmp/pids/resque.pid
    start program = "/bin/sh -c 'cd /var/www/project-name/current; PATH=/usr/local/bin:$PATH RAILS_ENV=production nohup bundle exec rake resque:work & >> log/resque.log 2>&1'" as uid deploy and gid deploy
    stop program = "/bin/sh -c 'cd /var/www/project-name/current && kill -9 `cat tmp/pids/resque.pid` && rm -f tmp/pids/resque.pid; exit 0;'"
    if totalmem is greater than 200 MB for 10 cycles then restart # eating up memory?
    group resque_workers

    check process sidekiq
    with pidfile /var/www/project-name/current/tmp/pids/sidekiq.pid
    start program = "/bin/sh -c 'cd /var/www/project-name/current; PATH=/usr/local/bin:$PATH RAILS_ENV=production bundle exec sidekiq -C config/sidekiq.yml -P tmp/pids/sidekiq.pid" as uid deploy
  3. raecoo revised this gist Feb 21, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions monit-example.txt
    Original file line number Diff line number Diff line change
    @@ -53,7 +53,7 @@ check process resque

    check process sidekiq
    with pidfile /var/www/project-name/current/tmp/pids/sidekiq.pid
    start program = "/bin/sh -c 'cd /var/www/project-name/current; PATH=/usr/local/bin:$PATH RAILS_ENV=production bundle exec sidekiq -C config/sidekiq.yml -P tmp/pids/sidekiq.pid" with timeout 90 seconds as uid deploy and gid deploy
    stop program = "/bin/sh -c 'cd /var/www/project-name/current && kill -s INT `cat tmp/pids/sidekiq.pid`'" without timeout 90 seconds
    start program = "/bin/sh -c 'cd /var/www/project-name/current; PATH=/usr/local/bin:$PATH RAILS_ENV=production bundle exec sidekiq -C config/sidekiq.yml -P tmp/pids/sidekiq.pid" as uid deploy
    stop program = "/bin/sh -c 'cd /var/www/project-name/current && kill -s INT `cat tmp/pids/sidekiq.pid`'"
    if totalmem is greater than 200 MB for 10 cycles then restart # eating up memory?
    group redis_workers
  4. raecoo created this gist Feb 21, 2013.
    59 changes: 59 additions & 0 deletions monit-example.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    set daemon 20
    set logfile syslog facility log_daemon
    set mailserver smtp.gmail.com port 587
    username "ERROR-EMAIL-ADDRESS" password "PASSWORD"
    using tlsv1
    with timeout 30 seconds

    set alert ERROR-EMAIL-ADDRESS

    set httpd port 2812 and
    use address localhost
    allow localhost
    allow admin:monit
    check system localhost
    if loadavg (1min) > 4 then alert
    if loadavg (5min) > 2 then alert
    if memory usage > 90% then alert
    if cpu usage (user) > 70% then alert
    if cpu usage (system) > 30% then alert
    if cpu usage (wait) > 20% then alert

    check process nginx
    with pidfile /var/run/nginx.pid
    group www
    start program = "/etc/init.d/nginx start"
    stop program = "/etc/init.d/nginx stop"
    if children > 250 then restart
    if loadavg(5min) greater than 10 for 8 cycles then stop
    if 3 restarts within 5 cycles then timeout

    check process mysql
    with pidfile /var/run/mysqld/mysqld.pid
    group database
    start program = "/etc/init.d/mysql start"
    stop program = "/etc/init.d/mysql stop"
    if failed host localhost port 3306 protocol mysql then restart
    if 5 restarts within 5 cycles then timeout

    check process redis
    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 failed host 127.0.0.1 port 6379 then restart
    if 5 restarts within 5 cycles then timeout
    group redis_workers

    check process resque
    with pidfile /var/www/project-name/current/tmp/pids/resque.pid
    start program = "/bin/sh -c 'cd /var/www/project-name/current; PATH=/usr/local/bin:$PATH RAILS_ENV=production nohup bundle exec rake resque:work & >> log/resque.log 2>&1'" as uid deploy and gid deploy
    stop program = "/bin/sh -c 'cd /var/www/project-name/current && kill -9 `cat tmp/pids/resque.pid` && rm -f tmp/pids/resque.pid; exit 0;'"
    if totalmem is greater than 200 MB for 10 cycles then restart # eating up memory?
    group resque_workers

    check process sidekiq
    with pidfile /var/www/project-name/current/tmp/pids/sidekiq.pid
    start program = "/bin/sh -c 'cd /var/www/project-name/current; PATH=/usr/local/bin:$PATH RAILS_ENV=production bundle exec sidekiq -C config/sidekiq.yml -P tmp/pids/sidekiq.pid" with timeout 90 seconds as uid deploy and gid deploy
    stop program = "/bin/sh -c 'cd /var/www/project-name/current && kill -s INT `cat tmp/pids/sidekiq.pid`'" without timeout 90 seconds
    if totalmem is greater than 200 MB for 10 cycles then restart # eating up memory?
    group redis_workers