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.
4 comments
that’s pretty cool.
You probably don’t need the port loop.
So, this doesn’t actually monitor apache, it just executes apachectl start every five seconds, so yeah, apache is always running…
Try: god -c /path/to/your_conf.god -D
The -D makes god not go into the background, and you can watch it try to restart apache constantly.
Adding a line like the following will allow God to check the pid of the process before determining it is not running:
w.pid_file = ‘/var/run/httpd.pid’
Regards,
-david
good post..it always been easy to configure the apache, just follow the steps and restart it and you can get your server configured ..but you need to monitor it everytime to ensure its uptime..
2 Trackbacks
[...] 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. [...]
[...] Monitoring apache with god | grits [...]