views:

451

answers:

2

I have a Apache + Haproxy + Mongrel Cluster setup. I want to receive alerts whenever my Mongrel queue length gets too high.

How to I get the current Mongrel Queue length and make it available for alerting tools such as Monit and Nagios?

I know that Haproxy has the information about Mongrel queue as it intelligently sends requests to least busy Mongrel in the cluster. I wonder how it finds out? I need a similar mechanism to generate alerts and/or restart mongrels when such a condition arrives.

A: 

New Relic's RPM product (www.newrelic.com) maintains information on Mongrel queue length. They have an API that you may be able to use to get near real-time feedback on queue length and adjust load balancing accordingly.

You can get more information on the API at: https://newrelic.tenderapp.com/faqs/docs/data-api

Hopefully that provides some help.

md
+1  A: 

Add this to your haproxy config

        stats uri /haproxy/hastats

Then use lynx to get the stats like this: (assuming haproxy runs on port 10000 - adjust to suit)

 lynx --dump http://my-server:10000/haproxy/hastats

Each there will be a line for each of your server entries in the haproxy config file, telling you whether it's up or down, how long it's queue is, like this:

            Server                 Queue             Sessions                    Errors
  Name    Weight Status Act. Bck. Curr. Max. Curr. Max. Limit  Cumul.   Conn. Resp. Sec. Check Down
primary     1      UP    Y    -      0    0    68  386     - 134385861   207   699    0  7028  150
secondary    1      UP    Y    -      0    0    71  248     - 134464984   216   551    0  7129   98

Now all you need is a script to get the current queue (column 6) and feed it into nagios, and you're away!

Chris May