[MEDIUM] add support for health-checks on other addresses
Patch from Fabrice Dulaunoy. Explanation below, and script
merged in examples/.
This patch allow to put a different address in the check part for each
server (and not only a specific port)
I need this feature because I've a complex settings where, when a specific
farm goes down, I need to switch a set of other farm either if these other
farm behave perfectly well.
For that purpose, I've made a small PERL daemon with some REGEX or PORT
test which allow me to test a bunch of thing.
diff --git a/src/checks.c b/src/checks.c
index ed0873a..295be15 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -248,8 +248,18 @@
(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *) &one, sizeof(one)) != -1)) {
//fprintf(stderr, "process_chk: 3\n");
+
+ if ( s->set_check_addr == 1 )
+ {
+ /* we'll connect to the check addr specified on the server */
+ sa = s->check_addr;
+ }
+ else
+ {
+ /* we'll connect to the addr on the server */
+ sa = s->addr;
+ }
/* we'll connect to the check port on the server */
- sa = s->addr;
sa.sin_port = htons(s->check_port);
/* allow specific binding :