summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd/log.c
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2008-12-05 16:37:57 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2008-12-05 16:37:57 +0000
commit06c9bb7c95e6c25ec6f881eee3b45305acb8f2ce (patch)
tree119b5d41c71dbfd96423fbcd35fc4eaf2d22a598 /usr.sbin/relayd/log.c
parent895ba5653d9df3632e9079b039cf884b57a73d38 (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/log.c')
-rw-r--r--usr.sbin/relayd/log.c107
1 files changed, 106 insertions, 1 deletions
diff --git a/usr.sbin/relayd/log.c b/usr.sbin/relayd/log.c
index b5cf7e80cfc..411d08c442d 100644
--- a/usr.sbin/relayd/log.c
+++ b/usr.sbin/relayd/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.13 2008/07/18 12:26:52 reyk Exp $ */
+/* $OpenBSD: log.c,v 1.14 2008/12/05 16:37:55 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -167,6 +167,111 @@ fatalx(const char *emsg)
}
const char *
+host_error(enum host_error he)
+{
+ switch (he) {
+ case HCE_NONE:
+ return ("none");
+ break;
+ case HCE_ABORT:
+ return ("aborted");
+ break;
+ case HCE_INTERVAL_TIMEOUT:
+ return ("interval timeout");
+ break;
+ case HCE_ICMP_OK:
+ return ("icmp ok");
+ break;
+ case HCE_ICMP_READ_TIMEOUT:
+ return ("icmp read timeout");
+ break;
+ case HCE_ICMP_WRITE_TIMEOUT:
+ return ("icmp write timeout");
+ break;
+ case HCE_TCP_CONNECT_ERROR:
+ return ("tcp connect error");
+ break;
+ case HCE_TCP_CONNECT_FAIL:
+ return ("tcp connect failed");
+ break;
+ case HCE_TCP_CONNECT_TIMEOUT:
+ return ("tcp connect timeout");
+ break;
+ case HCE_TCP_CONNECT_OK:
+ return ("tcp connect ok");
+ break;
+ case HCE_TCP_WRITE_TIMEOUT:
+ return ("tcp write timeout");
+ break;
+ case HCE_TCP_WRITE_FAIL:
+ return ("tcp write failed");
+ break;
+ case HCE_TCP_READ_TIMEOUT:
+ return ("tcp read timeout");
+ break;
+ case HCE_TCP_READ_FAIL:
+ return ("tcp read failed");
+ break;
+ case HCE_SCRIPT_OK:
+ return ("script ok");
+ break;
+ case HCE_SCRIPT_FAIL:
+ return ("script failed");
+ break;
+ case HCE_SSL_CONNECT_OK:
+ return ("ssl connect ok");
+ break;
+ case HCE_SSL_CONNECT_FAIL:
+ return ("ssl connect failed");
+ break;
+ case HCE_SSL_CONNECT_TIMEOUT:
+ return ("ssl connect timeout");
+ break;
+ case HCE_SSL_CONNECT_ERROR:
+ return ("ssl connect error");
+ break;
+ case HCE_SSL_READ_TIMEOUT:
+ return ("ssl read timeout");
+ break;
+ case HCE_SSL_WRITE_TIMEOUT:
+ return ("ssl write timeout");
+ break;
+ case HCE_SSL_READ_ERROR:
+ return ("ssl read error");
+ break;
+ case HCE_SSL_WRITE_ERROR:
+ return ("ssl write error");
+ break;
+ case HCE_SEND_EXPECT_FAIL:
+ return ("send/expect failed");
+ break;
+ case HCE_SEND_EXPECT_OK:
+ return ("send/expect ok");
+ break;
+ case HCE_HTTP_CODE_ERROR:
+ return ("http code malformed");
+ break;
+ case HCE_HTTP_CODE_FAIL:
+ return ("http code mismatch");
+ break;
+ case HCE_HTTP_CODE_OK:
+ return ("http code ok");
+ break;
+ case HCE_HTTP_DIGEST_ERROR:
+ return ("http digest malformed");
+ break;
+ case HCE_HTTP_DIGEST_FAIL:
+ return ("http digest mismatch");
+ break;
+ case HCE_HTTP_DIGEST_OK:
+ return ("http digest ok");
+ break;
+ }
+ /* NOTREACHED */
+ return ("invalid");
+}
+
+const char *
host_status(enum host_status status)
{
switch (status) {