MEDIUM: checks: Implement postgres check using tcp-check rules
A shared tcp-check ruleset is now created to support postgres check. This way no
extra memory is used if several backends use a pgsql check.
The following sequence is used :
tcp-check connect default linger
tcp-check send-binary PGSQL_REQ log-format
tcp-check expect !rstring "^E" min-recv 5 \
error-status "L7RSP" on-error "%[check.payload(6,0)]"
tcp-check expect rbinary "^520000000800000000 min-recv "9" \
error-status "L7STS" \
on-success "PostgreSQL server is ok" \
on-error "PostgreSQL unknown error"
The log-format hexa string PGSQL_REQ depends on 2 preset variables, the packet
length (check.plen) and the username (check.username).
diff --git a/include/types/checks.h b/include/types/checks.h
index 541666c..9b34cbe 100644
--- a/include/types/checks.h
+++ b/include/types/checks.h
@@ -312,6 +312,7 @@
#define TCPCHK_RULES_SHARED 0x00000001 /* Set for shared list of tcp-check rules */
#define TCPCHK_RULES_DEF 0x00000002 /* Ruleset inherited from the default section */
+#define TCPCHK_RULES_PGSQL_CHK 0x00000010
#define TCPCHK_RULES_REDIS_CHK 0x00000020
#define TCPCHK_RULES_SMTP_CHK 0x00000030
#define TCPCHK_RULES_SSL3_CHK 0x00000070
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 0f4301d..be5b5c9 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -169,9 +169,7 @@
/* server health checks */
#define PR_O2_CHK_NONE 0x00000000 /* no L7 health checks configured (TCP by default) */
-#define PR_O2_PGSQL_CHK 0x10000000 /* use PGSQL check for server health */
-/* unused: 0x20000000 */
-/* unused 0x30000000 */
+/* unused: 0x10000000..0x30000000 */
#define PR_O2_HTTP_CHK 0x40000000 /* use HTTP 'OPTIONS' method to check server health */
#define PR_O2_MYSQL_CHK 0x50000000 /* use MYSQL check for server health */
#define PR_O2_LDAP_CHK 0x60000000 /* use LDAP check for server health */