blob: d7d9725329bdf925ddde60e6b5afd299a79921a3 [file] [log] [blame]
Krzysztof Piotr Oledzki09605412009-09-23 22:09:24 +02001/*
2 * Health-checks.
3 *
4 * Copyright 2008-2009 Krzysztof Piotr Oledzki <ole@ans.pl>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
Thierry FOURNIER7eeb4352013-06-14 15:28:25 +020013#ifndef _TYPES_CHECKS_H
14#define _TYPES_CHECKS_H
15
Krzysztof Piotr Oledzki09605412009-09-23 22:09:24 +020016/* check status */
17enum {
18 HCHK_STATUS_UNKNOWN = 0, /* Unknown */
19 HCHK_STATUS_INI, /* Initializing */
Krzysztof Piotr Oledzki213014e2009-09-27 15:50:02 +020020 HCHK_STATUS_START, /* Check started - SPECIAL STATUS */
Krzysztof Piotr Oledzki09605412009-09-23 22:09:24 +020021
Krzysztof Piotr Oledzki213014e2009-09-27 15:50:02 +020022 /* Below we have finished checks */
Krzysztof Piotr Oledzki09605412009-09-23 22:09:24 +020023 HCHK_STATUS_CHECKED, /* DUMMY STATUS */
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +010024
Simon Hormanb7cd8f92012-03-19 07:25:28 +090025 HCHK_STATUS_HANA, /* Health analyze detected enough consecutive errors */
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +010026
Krzysztof Piotr Oledzki09605412009-09-23 22:09:24 +020027 HCHK_STATUS_SOCKERR, /* Socket error */
28
29 HCHK_STATUS_L4OK, /* L4 check passed, for example tcp connect */
30 HCHK_STATUS_L4TOUT, /* L4 timeout */
31 HCHK_STATUS_L4CON, /* L4 connection problem, for example: */
32 /* "Connection refused" (tcp rst) or "No route to host" (icmp) */
33
34 HCHK_STATUS_L6OK, /* L6 check passed */
35 HCHK_STATUS_L6TOUT, /* L6 (SSL) timeout */
36 HCHK_STATUS_L6RSP, /* L6 invalid response - protocol error */
37
38 HCHK_STATUS_L7TOUT, /* L7 (HTTP/SMTP) timeout */
39 HCHK_STATUS_L7RSP, /* L7 invalid response - protocol error */
40
Simon Hormanb7cd8f92012-03-19 07:25:28 +090041 /* Below we have layer 5-7 data available */
Krzysztof Piotr Oledzki09605412009-09-23 22:09:24 +020042 HCHK_STATUS_L57DATA, /* DUMMY STATUS */
43 HCHK_STATUS_L7OKD, /* L7 check passed */
44 HCHK_STATUS_L7OKCD, /* L7 check conditionally passed */
45 HCHK_STATUS_L7STS, /* L7 response error, for example HTTP 5xx */
46
47 HCHK_STATUS_SIZE
48};
Krzysztof Piotr Oledzki213014e2009-09-27 15:50:02 +020049
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +010050
51/* health status for response tracking */
52enum {
53 HANA_STATUS_UNKNOWN = 0,
54
55 HANA_STATUS_L4_OK, /* L4 successful connection */
56 HANA_STATUS_L4_ERR, /* L4 unsuccessful connection */
57
58 HANA_STATUS_HTTP_OK, /* Correct http response */
59 HANA_STATUS_HTTP_STS, /* Wrong http response, for example HTTP 5xx */
60 HANA_STATUS_HTTP_HDRRSP, /* Invalid http response (headers) */
61 HANA_STATUS_HTTP_RSP, /* Invalid http response */
62
63 HANA_STATUS_HTTP_READ_ERROR, /* Read error */
64 HANA_STATUS_HTTP_READ_TIMEOUT, /* Read timeout */
65 HANA_STATUS_HTTP_BROKEN_PIPE, /* Unexpected close from server */
66
67 HANA_STATUS_SIZE
68};
69
70enum {
71 HANA_ONERR_UNKNOWN = 0,
72
73 HANA_ONERR_FASTINTER, /* Force fastinter*/
74 HANA_ONERR_FAILCHK, /* Simulate a failed check */
75 HANA_ONERR_SUDDTH, /* Enters sudden death - one more failed check will mark this server down */
76 HANA_ONERR_MARKDWN, /* Mark this server down, now! */
77};
78
79enum {
Simon Hormane0d1bfb2011-06-21 14:34:58 +090080 HANA_ONMARKEDDOWN_NONE = 0,
Simon Hormane0d1bfb2011-06-21 14:34:58 +090081 HANA_ONMARKEDDOWN_SHUTDOWNSESSIONS, /* Shutdown peer sessions */
82};
83
84enum {
Justin Karnegeseb2c24a2012-05-24 15:28:52 -070085 HANA_ONMARKEDUP_NONE = 0,
86 HANA_ONMARKEDUP_SHUTDOWNBACKUPSESSIONS, /* Shutdown peer sessions */
87};
88
89enum {
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +010090 HANA_OBS_NONE = 0,
91
92 HANA_OBS_LAYER4, /* Observe L4 - for example tcp */
93 HANA_OBS_LAYER7, /* Observe L7 - for example http */
94
95 HANA_OBS_SIZE
96};
97
Krzysztof Piotr Oledzki213014e2009-09-27 15:50:02 +020098struct check_status {
99 short result; /* one of SRV_CHK_* */
100 char *info; /* human readable short info */
101 char *desc; /* long description */
102};
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +0100103
104struct analyze_status {
105 char *desc; /* description */
106 unsigned char lr[HANA_OBS_SIZE]; /* result for l4/l7: 0 = ignore, 1 - error, 2 - OK */
107};
Thierry FOURNIER7eeb4352013-06-14 15:28:25 +0200108
Baptiste Assmann5ecb77f2013-10-06 23:24:13 +0200109/* bits for tcpcheck_rule->action */
110enum {
111 TCPCHK_ACT_SEND = 1, /* send action, regular string format */
112 TCPCHK_ACT_EXPECT, /* expect action, either regular or binary string */
113};
114
115struct tcpcheck_rule {
116 struct list list; /* list linked to from the proxy */
117 int action; /* action: send or expect */
118 /* match type uses NON-NULL pointer from either string or expect_regex below */
119 /* sent string is string */
120 char *string; /* sent or expected string */
121 int string_len; /* string lenght */
122 regex_t *expect_regex; /* expected */
123 int inverse; /* 0 = regular match, 1 = inverse match */
124};
125
Thierry FOURNIER7eeb4352013-06-14 15:28:25 +0200126#endif /* _TYPES_CHECKS_H */