blob: 029c20dfe813ef3e7aeb500e41510f1a63183095 [file] [log] [blame]
Willy Tarreau67b5a162019-08-11 16:38:56 +02001/*
2 * include/types/sink.h
3 * This file provides definitions for event sinks
4 *
5 * Copyright (C) 2000-2019 Willy Tarreau - w@1wt.eu
6 *
7 * 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
22#ifndef _TYPES_SINK_H
23#define _TYPES_SINK_H
24
25#include <common/buffer.h>
26#include <common/compat.h>
27#include <common/config.h>
28#include <common/ist.h>
29
Willy Tarreau4ed23ca2019-08-23 15:47:49 +020030/* A sink may be of 4 distinct types :
Willy Tarreau973e6622019-08-20 11:57:52 +020031 * - file descriptor (such as stdout)
Willy Tarreau4ed23ca2019-08-23 15:47:49 +020032 * - ring buffer, readable from CLI
Willy Tarreau67b5a162019-08-11 16:38:56 +020033 */
34enum sink_type {
35 SINK_TYPE_NEW, // not yet initialized
Willy Tarreau973e6622019-08-20 11:57:52 +020036 SINK_TYPE_FD, // events sent to a file descriptor
Willy Tarreau4ed23ca2019-08-23 15:47:49 +020037 SINK_TYPE_BUFFER, // events sent to a ring buffer
Willy Tarreau67b5a162019-08-11 16:38:56 +020038};
39
40/* This indicates the default event format, which is the destination's
41 * preferred format, but may be overridden by the source.
42 */
43enum sink_fmt {
44 SINK_FMT_RAW, // raw text sent as-is
45 SINK_FMT_SHORT, // raw text prefixed with a syslog level
46 SINK_FMT_ISO, // raw text prefixed with ISO time
47 SINK_FMT_TIMED, // syslog level then ISO
48 SINK_FMT_RFC3164, // regular syslog
49 SINK_FMT_RFC5424, // extended syslog
50};
51
Emeric Brun494c5052020-05-28 11:13:15 +020052struct sink_forward_target {
53 struct server *srv; // used server
54 struct appctx *appctx; // appctx of current session
55 size_t ofs; // ring buffer reader offset
56 __decl_hathreads(HA_SPINLOCK_T lock); // lock to protect current struct
57 struct sink_forward_target *next;
58};
59
Willy Tarreau67b5a162019-08-11 16:38:56 +020060/* describes the configuration and current state of an event sink */
61struct sink {
62 struct list sink_list; // position in the sink list
Emeric Brun99c453d2020-05-25 15:01:04 +020063 char *name; // sink name
64 char *desc; // sink description
Willy Tarreau67b5a162019-08-11 16:38:56 +020065 enum sink_fmt fmt; // format expected by the sink
66 enum sink_type type; // type of storage
Willy Tarreau67b5a162019-08-11 16:38:56 +020067 uint32_t maxlen; // max message length (truncated above)
Emeric Brun494c5052020-05-28 11:13:15 +020068 struct proxy* forward_px; // proxy used to forward
69 struct sink_forward_target *sft; // sink forward targets
70 struct task *forward_task; // task to handle forward targets conns
71 struct sig_handler *forward_sighandler; /* signal handler */
Willy Tarreau67b5a162019-08-11 16:38:56 +020072 struct {
Willy Tarreau8f240232019-08-27 16:41:06 +020073 __decl_hathreads(HA_RWLOCK_T lock); // shared/excl for dropped
Willy Tarreau4ed23ca2019-08-23 15:47:49 +020074 struct ring *ring; // used by ring buffer and STRM sender
Willy Tarreau67b5a162019-08-11 16:38:56 +020075 unsigned int dropped; // dropped events since last one.
Willy Tarreau973e6622019-08-20 11:57:52 +020076 int fd; // fd num for FD type sink
Willy Tarreau67b5a162019-08-11 16:38:56 +020077 } ctx;
78};
79
80#endif /* _TYPES_SINK_H */
81
82/*
83 * Local variables:
84 * c-indent-level: 8
85 * c-basic-offset: 8
86 * End:
87 */