Question: I am currently running a large rails application on a virtual server. My setup uses Unicorn to serve the Rails App with nginx as the proxy server in front. 

Occasionally I get notifications that My CPU usage has pegged for a long amount of time. Then I login and use htop to find the badly behaving process to kill it. Those misbehaving processes always seem to be unicorn workers. 

What I am wanting to know is, if there is a way to setup monit, or god to monitor these 'child processes' of unicorn and kill them if they hang at high cpu usage for a long period of time. I know how to monitor the unicorn master process because it writes it's process id to a PID file. But it is never the master process, only the child processes the misbehave.

Answer: 
You might want to try the process outlined here:
[Where Unicorns go to die: Watching unicorn workers with monit](http://www.stopdropandrew.com/2010/06/01/where-unicorns-go-to-die-watching-unicorn-workers-with-monit.html)

I haven't done it yet, but I'm going to give it a shot shortly.

**Edit:** It works really well. I'm using the methods there in production now.
I use God to monitor my Unicorns (That just sounds too cool). I've been using the same configuration as GitHub use outlined [here](https://github.com/blog/519-unicorn-god). In the second Gist you'll see a custom script written to monitor unicorn workers. It's a little hacky, but it works well. I believe something like this is to be merged into God at some point. But I haven't heard anything about that in a while.