I searched for "monitor" in the archives and read back about a year, and didn't 
see this asked.  I did see 

Apologies if it's something that has already been asked and answered.

In my application it would be useful to have multiple monitors, because I'd 
like to use HAProxy as a poor man's network monitor, since it already knows the 
state of each of its backends.

So, for example, if I had three backends--let's call them "static", "app", and 
"service"--I'd like to be able to define:

/monitor/alive
/monitor/healthy

Those would be true if, in the first case, at least one instance of each 
backend was OK, and in the second case, if all instances of all backends were 
OK.

Then I'd also like:

/monitor/static/alive
/monitor/static/healthy

and so on for app and service.  *THEN* I could simply iterate through my list 
of monitor endpoints and quickly build a graph of the system's overall health.

As it stands, though, you get one monitor URI per frontend.  It looks like it 
would take some surgery to turn that from a simple string to a hash associating 
names with particular monitors, and then a separate pointer per name referring 
to an ACL to do the monitor fail condition.  So I'm wondering the following:

1) is this a lot harder than it looks?  Obviously there's a bit more 
computation to do the "is this URI a monitor-uri hash key?  If, look up the 
associated ACL" than the strcmp it currently is.  That doesn't feel like it 
should be a huge performance penalty, but, well, a C hash is a lot heavier than 
a strcmp.  Even so, strmap (http://pokristensson.com/strmap.html) (which 
requires both keys and values to be strings, so it's not a totally generic hash 
implementation) would be perfectly OK for this purpose, and it's LGPL, so 
should be safe to integrate.

2) Am I thinking about this the wrong way?  That is, is the thing I want to do 
just silly and I should be going about it some other way?

3) Am I really the first person to make this feature request?  It seems like an 
obvious thing to want to do.  I seem to recall at some point finding some 
discussion that you could do this by chaining haproxies, but that seems much 
heavier-weight than just implementing:

monitor-hash app-healthy /monitor/app/healthy
monitor-fail-hash app-healthy nbserv(app) lt 4

Thanks,
Adam

Reply via email to