blob: bb275c8de205b7794971335b1ab87232605400cd [file] [log] [blame]
Willy TARREAU3dc06442006-06-15 21:48:13 +02001/*
Willy Tarreaubaaee002006-06-26 02:48:02 +02002 include/proto/checks.h
3 Functions prototypes for the checks.
4
Willy Tarreau26c25062009-03-08 09:38:41 +01005 Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu
Christopher Fauletfbcc77c2020-04-01 20:54:05 +02006
Willy TARREAU3dc06442006-06-15 21:48:13 +02007 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation, version 2.1
10 exclusively.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
Willy Tarreaubaaee002006-06-26 02:48:02 +020022#ifndef _PROTO_CHECKS_H
23#define _PROTO_CHECKS_H
24
25#include <types/task.h>
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020026#include <common/config.h>
Christopher Faulet0108bb32017-10-20 21:34:32 +020027#include <types/mailers.h>
Willy TARREAU3dc06442006-06-15 21:48:13 +020028
Gaetan Rivet13a50432020-02-21 18:13:44 +010029#include <types/action.h>
30
Krzysztof Piotr Oledzki09605412009-09-23 22:09:24 +020031const char *get_check_status_description(short check_status);
32const char *get_check_status_info(short check_status);
Willy Tarreau9fe7aae2013-12-31 23:47:37 +010033void __health_adjust(struct server *s, short status);
Willy Tarreaubaaee002006-06-26 02:48:02 +020034
Willy Tarreaubc174aa2012-11-19 16:10:32 +010035extern struct data_cb check_conn_cb;
36
Willy Tarreau9fe7aae2013-12-31 23:47:37 +010037/* Use this one only. This inline version only ensures that we don't
38 * call the function when the observe mode is disabled.
39 */
40static inline void health_adjust(struct server *s, short status)
41{
Christopher Faulet2a944ee2017-11-07 10:42:54 +010042 HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
Willy Tarreau9fe7aae2013-12-31 23:47:37 +010043 /* return now if observing nor health check is not enabled */
Emeric Brun9f0b4582017-10-23 14:39:51 +020044 if (!s->observe || !s->check.task) {
Christopher Faulet2a944ee2017-11-07 10:42:54 +010045 HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
Willy Tarreau9fe7aae2013-12-31 23:47:37 +010046 return;
Emeric Brun9f0b4582017-10-23 14:39:51 +020047 }
Willy Tarreau9fe7aae2013-12-31 23:47:37 +010048
Emeric Brun9f0b4582017-10-23 14:39:51 +020049 __health_adjust(s, status);
Christopher Faulet2a944ee2017-11-07 10:42:54 +010050 HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
Willy Tarreau9fe7aae2013-12-31 23:47:37 +010051}
52
Simon Hormanbfb5d332015-01-30 11:22:55 +090053void free_check(struct check *check);
Simon Hormanb1900d52015-01-30 11:22:54 +090054
Christopher Faulet0108bb32017-10-20 21:34:32 +020055int init_email_alert(struct mailers *mailers, struct proxy *p, char **err);
Simon Horman64e34162015-02-06 11:11:57 +090056void send_email_alert(struct server *s, int priority, const char *format, ...)
57 __attribute__ ((format(printf, 3, 4)));
Christopher Fauletba7bc162016-11-07 21:07:38 +010058
Gaetan Rivet707b52f2020-02-21 18:14:59 +010059extern struct action_kw_list tcp_check_keywords;
60static inline void tcp_check_keywords_register(struct action_kw_list *kw_list)
61{
62 LIST_ADDQ(&tcp_check_keywords.list, &kw_list->list);
63}
64
Christopher Faulet5d503fc2020-03-30 20:34:34 +020065void deinit_proxy_tcpcheck(struct proxy *px);
Christopher Faulet7a1e2e12020-04-02 18:05:11 +020066int dup_tcpcheck_vars(struct list *dst, struct list *src);
67
Christopher Fauletba7bc162016-11-07 21:07:38 +010068/* Declared here, but the definitions are in flt_spoe.c */
Christopher Faulet8ef75252017-02-20 22:56:03 +010069int spoe_prepare_healthcheck_request(char **req, int *len);
70int spoe_handle_healthcheck_response(char *frame, size_t size, char *err, int errlen);
Christopher Fauletba7bc162016-11-07 21:07:38 +010071
Christopher Faulet33f05df2020-04-01 11:08:50 +020072int proxy_parse_redis_check_opt(char **args, int cur_arg, struct proxy *curpx, struct proxy *defpx,
73 const char *file, int line);
Christopher Faulet811f78c2020-04-01 11:10:27 +020074int proxy_parse_ssl_hello_chk_opt(char **args, int cur_arg, struct proxy *curpx, struct proxy *defpx,
75 const char *file, int line);
Christopher Fauletfbcc77c2020-04-01 20:54:05 +020076int proxy_parse_smtpchk_opt(char **args, int cur_arg, struct proxy *curpx, struct proxy *defpx,
Christopher Fauletce355072020-04-02 11:44:39 +020077 const char *file, int line);
78int proxy_parse_pgsql_check_opt(char **args, int cur_arg, struct proxy *curpx, struct proxy *defpx,
79 const char *file, int line);
Christopher Faulet811f78c2020-04-01 11:10:27 +020080
Willy Tarreaubaaee002006-06-26 02:48:02 +020081#endif /* _PROTO_CHECKS_H */
Willy TARREAU3dc06442006-06-15 21:48:13 +020082
Willy Tarreaubaaee002006-06-26 02:48:02 +020083/*
84 * Local variables:
85 * c-indent-level: 8
86 * c-basic-offset: 8
87 * End:
88 */