diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2008-12-05 16:37:57 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2008-12-05 16:37:57 +0000 |
commit | 06c9bb7c95e6c25ec6f881eee3b45305acb8f2ce (patch) | |
tree | 119b5d41c71dbfd96423fbcd35fc4eaf2d22a598 /usr.sbin/relayd/hce.c | |
parent | 895ba5653d9df3632e9079b039cf884b57a73d38 (diff) |
change the way relayd reports check results: instead of logging an
arbitrary string in debugging mode, it will store an error code
(HCE_*) for each host. the error code can be translated to a string
(in log.c) for debugging but it will also be passed to relayctl via
the control socket.
from a user point of view, this will print a human-readable error
message in the "relayctl show hosts" output if a host is down because
the check failed. the relayctl(8) manpage includes detailed
explanations of the error messages including mitigations for the
most-common problems.
ok jmc@ (manpages)
ok phessler@
Diffstat (limited to 'usr.sbin/relayd/hce.c')
-rw-r--r-- | usr.sbin/relayd/hce.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c index a851c1caf4d..2f2dca574c6 100644 --- a/usr.sbin/relayd/hce.c +++ b/usr.sbin/relayd/hce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hce.c,v 1.45 2008/09/29 15:12:22 reyk Exp $ */ +/* $OpenBSD: hce.c,v 1.46 2008/12/05 16:37:55 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -192,6 +192,7 @@ hce_disable_events(void) evtimer_del(&env->sc_ev); TAILQ_FOREACH(table, env->sc_tables, entry) { TAILQ_FOREACH(host, &table->hosts, entry) { + host->he = HCE_ABORT; event_del(&host->cte.ev); close(host->cte.s); } @@ -219,6 +220,8 @@ hce_launch_checks(int fd, short event, void *arg) imsg_compose(ibuf_pfe, IMSG_SYNC, 0, 0, -1, NULL, 0); TAILQ_FOREACH(table, env->sc_tables, entry) { TAILQ_FOREACH(host, &table->hosts, entry) { + if ((host->flags & F_CHECK_DONE) == 0) + host->he = HCE_INTERVAL_TIMEOUT; host->flags &= ~(F_CHECK_SENT|F_CHECK_DONE); event_del(&host->cte.ev); } @@ -269,7 +272,7 @@ hce_launch_checks(int fd, short event, void *arg) } void -hce_notify_done(struct host *host, const char *msg) +hce_notify_done(struct host *host, enum host_error he) { struct table *table; struct ctl_status st; @@ -278,8 +281,10 @@ hce_notify_done(struct host *host, const char *msg) u_int logopt; struct host *h; int hostup; + const char *msg; hostup = host->up; + host->he = he; if (host->up == HOST_DOWN && host->retry_cnt) { log_debug("hce_notify_done: host %s retry %d", @@ -297,7 +302,9 @@ hce_notify_done(struct host *host, const char *msg) st.up = host->up; st.check_cnt = host->check_cnt; st.retry_cnt = host->retry_cnt; + st.he = he; host->flags |= (F_CHECK_SENT|F_CHECK_DONE); + msg = host_error(he); if (msg) log_debug("hce_notify_done: %s (%s)", host->conf.name, msg); @@ -338,7 +345,7 @@ hce_notify_done(struct host *host, const char *msg) /* Notify for all other hosts that inherit the state from this one */ SLIST_FOREACH(h, &host->children, child) { h->up = hostup; - hce_notify_done(h, msg); + hce_notify_done(h, he); } } @@ -395,6 +402,7 @@ hce_dispatch_imsg(int fd, short event, void *ptr) host->up = HOST_UNKNOWN; host->check_cnt = 0; host->up_cnt = 0; + host->he = HCE_NONE; break; case IMSG_HOST_ENABLE: memcpy(&id, imsg.data, sizeof(id)); @@ -402,6 +410,7 @@ hce_dispatch_imsg(int fd, short event, void *ptr) fatalx("hce_dispatch_imsg: desynchronized"); host->flags &= ~(F_DISABLE); host->up = HOST_UNKNOWN; + host->he = HCE_NONE; break; case IMSG_TABLE_DISABLE: memcpy(&id, imsg.data, sizeof(id)); |