monit and god are two powerful process monitoring tools. If you’re developing a rails application running on vps, you’ll need to monitor your active processes/tasks (web server, database and application server … ) so to be advised when an error occurs.
Both tools use a specific DSL for defining processes, the main difference being that god uses ruby as configuration language.
May think “Cool! I can write in my beloved ruby”, but in my opinion monit configuration files are much clearer. At first sight monit configuration files are easily readable while god files use specific labels whose structure is not immediately understandble. Here’s an example of the same task written in monit and god:
### MONIT ### check process httpd with pidfile /etc/httpd/run/httpd.pid start program = "/etc/init.d/httpd start" stop program = "/etc/init.d/httpd stop if failed port 80 protocol http then restart if totalmem > 1024 MB for 2 cycles then restart if 5 restarts within 5 cycles then alert set alert foo@bar ### GOD ### God.watch do |w| w.name = "httpd" w.pid_file = "/var/run/httpd.pid" w.start = "/etc/init.d/httpd start" w.stop = "/etc/init.d/httpd stop" w.transition(:up, :start) do |on| on.condition(:process_running) do |c| c.running = false end end w.restart_if do |restart| restart.condition(:memory_usage) do |c| c.above = 1024.megabytes c.times = 2 end end w.transition([:start, :restart], :up) do |on| on.condition(:tries) do |c| c.times = 5 c.notify = 'foo@bar' end end
Another important feature that god lack is a web interface. Monit with few settings gives you a basic web interface, from which you can watch and control all your active processes.
Last but not least, monit’s website home page is really well done 😉