[MEDIUM] Collect & show information about last health check, v3

Collect information about last health check result,
including L7 code if possible (for example http or smtp
return code) and time took to finish last check.

Health check info is provided on both stats pages (html & csv)
and logged when a server is marked UP or DOWN. Currently active
check are marked with an asterisk, but only in html mode.

Currently there are 14 status codes:
  UNK     -> unknown

  INI     -> initializing
  SOCKERR -> socket error

  L4OK    -> check passed on layer 4, no upper layers testing enabled
  L4TOUT  -> layer 1-4 timeout
  L4CON   -> layer 1-4 connection problem, for example "Connection refused"
              (tcp rst) or "No route to host" (icmp)

  L6OK    -> check passed on layer 6
  L6TOUT  -> layer 6 (SSL) timeout
  L6RSP   -> layer 6 invalid response - protocol error

  L7OK    -> check passed on layer 7
  L7OKC   -> check conditionally passed on layer 7, for example
               404 with disable-on-404
  L7TOUT  -> layer 7 (HTTP/SMTP) timeout
  L7RSP   -> layer 7 invalid response - protocol error
  L7STS   -> layer 7 response error, for example HTTP 5xx
diff --git a/include/types/checks.h b/include/types/checks.h
new file mode 100644
index 0000000..87ff2c8
--- /dev/null
+++ b/include/types/checks.h
@@ -0,0 +1,41 @@
+/*
+ * Health-checks.
+ *
+ * Copyright 2008-2009 Krzysztof Piotr Oledzki <ole@ans.pl>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ */
+
+/* check status */
+enum {
+	HCHK_STATUS_UNKNOWN	 = 0,	/* Unknown */
+	HCHK_STATUS_INI,		/* Initializing */
+
+	/* Below we have check finished */
+	HCHK_STATUS_CHECKED,		/* DUMMY STATUS */
+	HCHK_STATUS_SOCKERR,		/* Socket error */
+
+	HCHK_STATUS_L4OK,		/* L4 check passed, for example tcp connect */
+	HCHK_STATUS_L4TOUT,		/* L4 timeout */
+	HCHK_STATUS_L4CON,		/* L4 connection problem, for example: */
+					/*  "Connection refused" (tcp rst) or "No route to host" (icmp) */
+
+	HCHK_STATUS_L6OK,		/* L6 check passed */
+	HCHK_STATUS_L6TOUT,		/* L6 (SSL) timeout */
+	HCHK_STATUS_L6RSP,		/* L6 invalid response - protocol error */
+
+	HCHK_STATUS_L7TOUT,		/* L7 (HTTP/SMTP) timeout */
+	HCHK_STATUS_L7RSP,		/* L7 invalid response - protocol error */
+
+	/* Below we have layer 5-7 data avaliable */
+	HCHK_STATUS_L57DATA,		/* DUMMY STATUS */
+	HCHK_STATUS_L7OKD,		/* L7 check passed */
+	HCHK_STATUS_L7OKCD,		/* L7 check conditionally passed */
+	HCHK_STATUS_L7STS,		/* L7 response error, for example HTTP 5xx */
+
+	HCHK_STATUS_SIZE
+};
diff --git a/include/types/server.h b/include/types/server.h
index f634b8a..3304004 100644
--- a/include/types/server.h
+++ b/include/types/server.h
@@ -35,6 +35,7 @@
 #include <types/proxy.h>
 #include <types/queue.h>
 #include <types/task.h>
+#include <types/checks.h>
 
 
 /* server flags */
@@ -74,7 +75,7 @@
 	struct server *next;
 	int state;				/* server state (SRV_*) */
 	int prev_state;				/* server state before last change (SRV_*) */
-	int  cklen;				/* the len of the cookie, to speed up checks */
+	int cklen;				/* the len of the cookie, to speed up checks */
 	int rdr_len;				/* the length of the redirection prefix */
 	char *cookie;				/* the id set in the cookie */
 	char *rdr_pfx;				/* the redirection prefix */
@@ -121,9 +122,12 @@
 	long long failed_checks, down_trans;	/* failed checks and up-down transitions */
 	unsigned down_time;			/* total time the server was down */
 	time_t last_change;			/* last time, when the state was changed */
+	struct timeval check_start;		/* last health check start time */
+	unsigned long check_duration;		/* time in ms took to finish last health check */
+	short check_status, check_code;		/* check result, check code */
 
 	long long failed_conns, failed_resp;	/* failed connect() and responses */
-	long long retries, redispatches;		/* retried and redispatched connections */
+	long long retries, redispatches;	/* retried and redispatched connections */
 	long long failed_secu;			/* blocked responses because of security concerns */
 	struct freq_ctr sess_per_sec;		/* sessions per second on this server */
 	unsigned int sps_max;			/* maximum of new sessions per second seen on this server */