Monitoring apache with god

According to the site: God is an easy to configure, easy to extend monitoring framework written in Ruby.

While god is mainly intended for monitoring mongrels it is also a great way to keep an eye on apache itself. Below is our config for watching apache.

%w{80}.each do |port|
  God.watch do |w|
    w.name = "apache"
    w.interval = 30.seconds # default
    w.start = "apachectl start"
    w.stop = "apachectl stop"
    w.restart = "apachectl restart"
    w.start_grace = 10.seconds
    w.restart_grace = 10.seconds

    w.start_if do |start|
      start.condition(:process_running) do |c|
          c.interval = 5.seconds
          c.running = false
      end
    end
  end
end

The code is pretty self-explanatory. We’re just looking to make sure apache is up every 5 seconds.

After gem installing god, save the configuration file anywhere you want and kick if off with this command:

god -c /path/to/your_conf.god

That’s it. To test, kill apache and in less than 5 seconds it will be back up and running.

2 comments

  1. caleb/
    March 11, 2008, 5:53 pm

    that’s pretty cool.

  2. Christian Romney/
    December 9, 2008, 2:23 pm

    You probably don’t need the port loop.

2 Trackbacks

  1. [...] After installing God sudo gem install god –no-ri –no-rdoc, setup a conf.god somewhere sensible and take a look at the posts below, as it probably doesn’t make sense for me to reiterate what others have already admirably accomplished: Monitoring MySQL and setting up notifications. Monitoring Apache. [...]

  2. [...] Monitoring apache with god | grits [...]

Add a comment

Your email is never published or shared. Required fields are marked *

*
*