Web Images Groups Directory
Recently Visited Groups | Help | Sign in
Google Groups Home
Group info
Members: 2118
Language: English
Group categories:
Computers > Software
Computers > Programming
More group info »
useful-recipies---monit    

Monit tasks 

 

For config/deploy.rb

 

  namespace :deploy do

    task :start do
      restart_monit
      sudo "/usr/bin/monit -g #{application} start all"
    end

    task :stop do
      restart_monit
      sudo "/usr/bin/monit -g #{application} stop all"
    end

    task :restart do
      restart_monit
      sudo "/usr/bin/monit -g #{application} restart all"
      run "echo \"Website has been deployed\""
    end

    desc "Copy monit base configuration"
    task :copy_monit_cfg_base do
      #sudo "cp #{release_path}/monit/etc_monitrc /etc/monitrc"
      #sudo "rm -rf /etc/monit.d/#{application}"
      #sudo "mkdir -p /etc/monit.d/#{application}"
      #sudo "cp #{release_path}/monit/disk_space.monitrc /etc/monit.d/#{application}"
    end

    desc "Stop monit"
    task :stop_monit do
      sudo "/etc/init.d/monit stop"
    end

    desc "Start monit"
    task :start_monit do
      sudo "/etc/init.d/monit start"
    end

    desc "Restart monit"
    task :restart_monit do
      stop_monit
      run  "sleep 5"
      start_monit
    end
  end



Monit scripts


ferret.monitrc:

  check process ferret with pidfile /www/application/current/log/ferret.pid
    start program = "/bin/su -c 'cd /www/application/current/ && RAILS_ENV=development FERRET_USE_LOCAL_INDEX=1 script/ferret_start' nobody"
    stop program = "/bin/su -c 'cd /www/application/current/ && RAILS_ENV=development FERRET_USE_LOCAL_INDEX=1 script/ferret_stop' nobody"

    # cpu usage boundaries
    if cpu > 60% for 2 cycles then alert
    if cpu > 90% for 5 cycles then restart

    # memory usage varies with index size and usage scenarios, so check how
    # much memory your DRb server uses up usually and add some spare to that
    # before enabling this rule:
    # if totalmem > 50.0 MB for 5 cycles then restart

    # roll log files (man page suggests writing a rotate script, but this is problematic for some apps)
    #if size > 50 MB then
    #  exec "mv /www/application/shared/log/ferret_index.log ferret"

    # adjust port numbers according to your setup:
    if failed port 9010 then alert
    if failed port 9010 for 2 cycles then restart
    group application

backgroundrb.monitrc:

  check process backgroundrb with pidfile /www/application/current/log/backgroundrb.pid
    start program = "/bin/su -c 'cd /www/application/current/ && RAILS_ENV=development script/backgroundrb start' nobody"
    stop program = "/bin/su -c 'cd /www/application/current/ && RAILS_ENV=development script/backgroundrb stop && sleep 3 && pkill -9 -f backgroundrb && rm /www/application/current/log/backgroundrb.pid' nobody"

    # cpu usage boundaries
    if cpu > 60% for 2 cycles then alert
    if cpu > 90% for 5 cycles then restart

    # file for communication
    if failed unix /tmp/backgroundrbunix_localhost_2000
      for 5 cycles then restart

    # memory usage varies with index size and usage scenarios, so check how
    # much memory your DRb server uses up usually and add some spare to that
    # before enabling this rule:
    # if totalmem > 50.0 MB for 5 cycles then restart

    group application

Version: 
Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google