/satan

Automated Process Reaper for Unix Systems

Primary LanguageRubyOtherNOASSERTION

Automated Process Reaper for Unix Systems

Satan does just one thing, and one thing only; kill processes. Satan was designed to work with Solaris’ SMF self-healing properties. Let Satan kill while SMF revive. The Satan name is a play off of the God Monitor http://god.rubyforge.org/ 

The reason Satan was developed was because God overlaps too much in functionality with SMF so it is not practical to run on Solaris.

Features

  - No dependencies aside from Ruby
  - Email notification on reaped processes
  - Easy to use DSL to define reaping rules
  - HTTP checks to reap based on non-200 response code
  
INSTALLATION

  - Install satan on your run path: /opt/bin;/opt/sfw/bin;/usr/bin
  - Edit satan.smf to your liking and import: svccfg import satan.smf

HOW TO USE

  - /opt/bin/satan ~/satan.cfg
    OR
  - via SMF, see installation block.

The configuration is all done in Ruby, clean and simple.

Satan.watch do |s|
  s.name = "jvm instances"                # name of job
  s.user = "webservd"                     # under what user
  s.group = "webservd"                    # under what group
  s.deamon = "java"                       # deamon binary name to grep for
  s.args = nil                            # globally look for specific arguments, optional
  s.debug = true                          # if to write out debug information
  s.safe_mode = false                     # If in safe mode, satan will not kill ;-(
  s.interval = 10.seconds                 # interval to run at to collect statistics
  s.sleep_after_kill = 1.minute           # sleep after killing, satan is tired!
  s.contact = "victori@fabulously40.com"  # admin contact, optional if you want email alerts
  
  s.kill_if do |process|
    process.condition(:cpu) do |cpu|      # on cpu condition
      cpu.name  = "50% CPU limit"         # name for job
      cpu.args  = "jetty"                 # make sure this is a jetty process, optional
      cpu.above = 48.percent              # if above certain percentage
      cpu.times = 5                       # how many times we can hit this condition before killing
    end
    
    process.condition(:memory) do |memory|  # on memory condition
      memory.name  = "850MB limit"          # name for job
      memory.args  = "jetty"                # make sure this is a jetty process, optional
      memory.above = 850.megabytes          # limit for memory use
      memory.times = 5                      # how many times we can hit this condition before killing
    end
    
    # ActiveMQ tends to die on us under heavy load so we need the power of satan!
    process.condition(:http) do |http|                        # on http condition
      http.name   = "HTTP ActiveMQ Check"                     # name for job
      http.args   = "8161"                                    # look for specific app arguments
                                                              # to associate app to URI
      http.uri    = "http://localhost:8161/admin/queues.jsp"  # the URI
      http.times  = 5                                         # how many times before the kill
    end
  end
end