MEDIUM: Set rise and fall of agent checks to 1
This is achieved by moving rise and fall from struct server to struct check.
After this move the behaviour of the primary check, server->check is
unchanged. However, the secondary agent check, server->agent now has
independent rise and fall values each of which are set to 1.
The result is that receiving "fail", "stopped" or "down" just once from the
agent will mark the server as down. And receiving a weight just once will
allow the server to be marked up if its primary check is in good health.
This opens up the scope to allow the rise and fall values of the agent
check to be configurable, however this has not been implemented at this
stage.
Signed-off-by: Simon Horman <horms@verge.net.au>
diff --git a/src/dumpstats.c b/src/dumpstats.c
index 99d16d7..3d60b09 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -1309,14 +1309,14 @@
*/
if (sv->track->state & SRV_RUNNING) {
set_server_up(&sv->check);
- sv->check.health = sv->rise; /* up, but will fall down at first failure */
+ sv->check.health = sv->check.rise; /* up, but will fall down at first failure */
} else {
sv->state &= ~SRV_MAINTAIN;
set_server_down(&sv->check);
}
} else {
set_server_up(&sv->check);
- sv->check.health = sv->rise; /* up, but will fall down at first failure */
+ sv->check.health = sv->check.rise; /* up, but will fall down at first failure */
}
}
@@ -2266,8 +2266,8 @@
chunk_appendf(&trash, "%s ", human_time(now.tv_sec - ref->last_change, 1));
chunk_appendf(&trash,
srv_hlt_st[state],
- (ref->state & SRV_RUNNING) ? (ref->check.health - ref->rise + 1) : (ref->check.health),
- (ref->state & SRV_RUNNING) ? (ref->fall) : (ref->rise));
+ (ref->state & SRV_RUNNING) ? (ref->check.health - ref->check.rise + 1) : (ref->check.health),
+ (ref->state & SRV_RUNNING) ? (ref->check.fall) : (ref->check.rise));
}
if (sv->state & SRV_CHECKED) {
@@ -2374,8 +2374,8 @@
else
chunk_appendf(&trash,
srv_hlt_st[state],
- (ref->state & SRV_RUNNING) ? (ref->check.health - ref->rise + 1) : (ref->check.health),
- (ref->state & SRV_RUNNING) ? (ref->fall) : (ref->rise));
+ (ref->state & SRV_RUNNING) ? (ref->check.health - ref->check.rise + 1) : (ref->check.health),
+ (ref->state & SRV_RUNNING) ? (ref->check.fall) : (ref->check.rise));
chunk_appendf(&trash,
/* weight, active, backup */
@@ -2944,7 +2944,7 @@
if (!(svs->state & SRV_CHECKED))
sv_state = 6;
else if (svs->state & SRV_RUNNING) {
- if (svs->check.health == svs->rise + svs->fall - 1)
+ if (svs->check.health == svs->check.rise + svs->check.fall - 1)
sv_state = 3; /* UP */
else
sv_state = 2; /* going down */