diff options
author | Sebastian Benoit <benno@cvs.openbsd.org> | 2016-01-11 21:31:43 +0000 |
---|---|---|
committer | Sebastian Benoit <benno@cvs.openbsd.org> | 2016-01-11 21:31:43 +0000 |
commit | 577d8583deb3bbb4b656f84c8128ce95a2981d70 (patch) | |
tree | 5537240eb6e3ab9dc3ef42a11ebf0a950017fdb8 | |
parent | eafc50dc848b129c0b1826f0425ffb07c296f54c (diff) |
This adds the host_error output and the http code (when available) to the
host-check log.
ok claudio@
-rw-r--r-- | usr.sbin/relayd/check_tcp.c | 8 | ||||
-rw-r--r-- | usr.sbin/relayd/hce.c | 9 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 3 |
3 files changed, 14 insertions, 6 deletions
diff --git a/usr.sbin/relayd/check_tcp.c b/usr.sbin/relayd/check_tcp.c index 9ff40681c4e..05b7860827d 100644 --- a/usr.sbin/relayd/check_tcp.c +++ b/usr.sbin/relayd/check_tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check_tcp.c,v 1.50 2015/12/30 12:08:34 benno Exp $ */ +/* $OpenBSD: check_tcp.c,v 1.51 2016/01/11 21:31:42 benno Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -318,6 +318,7 @@ check_http_code(struct ctl_tcp_event *cte) head = cte->buf->buf; host = cte->host; host->he = HCE_HTTP_CODE_ERROR; + host->code = 0; if (strncmp(head, "HTTP/1.1 ", strlen("HTTP/1.1 ")) && strncmp(head, "HTTP/1.0 ", strlen("HTTP/1.0 "))) { @@ -340,10 +341,11 @@ check_http_code(struct ctl_tcp_event *cte) return (1); } if (code != cte->table->conf.retcode) { - log_debug("%s: %s failed (invalid HTTP code returned)", - __func__, host->conf.name); + log_debug("%s: %s failed (invalid HTTP code %d returned)", + __func__, host->conf.name, code); host->he = HCE_HTTP_CODE_FAIL; host->up = HOST_DOWN; + host->code = code; } else { host->he = HCE_HTTP_CODE_OK; host->up = HOST_UP; diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c index 78832dfadd5..3772faa405d 100644 --- a/usr.sbin/relayd/hce.c +++ b/usr.sbin/relayd/hce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hce.c,v 1.71 2015/12/02 13:41:27 reyk Exp $ */ +/* $OpenBSD: hce.c,v 1.72 2016/01/11 21:31:42 benno Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -200,6 +200,7 @@ hce_notify_done(struct host *host, enum host_error he) struct host *h, *hostnst; int hostup; const char *msg; + char *codemsg = NULL; if ((hostnst = host_find(env, host->conf.id)) == NULL) fatalx("hce_notify_done: desynchronized"); @@ -257,12 +258,16 @@ hce_notify_done(struct host *host, enum host_error he) duration = 0; if (env->sc_opts & logopt) { - log_info("host %s, check %s%s (%lums), state %s -> %s, " + if (host->code > 0) + asprintf(&codemsg, ",%d", host->code); + log_info("host %s, check %s%s (%lums,%s%s), state %s -> %s, " "availability %s", host->conf.name, table_check(table->conf.check), (table->conf.flags & F_TLS) ? " use tls" : "", duration, + msg, (codemsg != NULL) ? codemsg : "", host_status(host->last_up), host_status(host->up), print_availability(host->check_cnt, host->up_cnt)); + free(codemsg); } host->last_up = host->up; diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index 81d90641bc2..42e76042dd1 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.221 2015/12/02 22:12:29 benno Exp $ */ +/* $OpenBSD: relayd.h,v 1.222 2016/01/11 21:31:42 benno Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -428,6 +428,7 @@ struct host { int retry_cnt; int idx; u_int16_t he; + int code; struct ctl_tcp_event cte; }; TAILQ_HEAD(hostlist, host); |