| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef NETDATA_STREAM_CONF_H |
| 4 | #define NETDATA_STREAM_CONF_H |
| 5 | |
| 6 | #include "libnetdata/libnetdata.h" |
| 7 | #include "stream-compression/compression.h" |
| 8 | #include "stream-capabilities.h" |
| 9 | #include "database/rrd-database-mode.h" |
| 10 | #include "daemon/config/netdata-conf-profile.h" |
| 11 | |
| 12 | #define SENDER_MIN_RECONNECT_DELAY 5 |
| 13 | |
| 14 | struct _stream_send { |
| 15 | bool enabled; |
| 16 | |
| 17 | STRING *api_key; |
| 18 | STRING *send_charts_matching; |
| 19 | |
| 20 | // to have the remote netdata re-sync the charts |
| 21 | // to its current clock, we send for this many |
| 22 | // iterations a BEGIN line without microseconds |
| 23 | // this is for the first iterations of each chart |
| 24 | uint16_t initial_clock_resync_iterations; |
| 25 | |
| 26 | uint32_t buffer_max_size; |
| 27 | |
| 28 | struct { |
| 29 | size_t prefetch; |
| 30 | size_t threads; |
| 31 | } replication; |
| 32 | |
| 33 | struct { |
| 34 | STRING *destination; |
| 35 | STRING *ssl_ca_path; |
| 36 | STRING *ssl_ca_file; |
| 37 | bool h2o; |
| 38 | uint16_t default_port; |
| 39 | time_t timeout_s; |
| 40 | time_t reconnect_delay_s; |
| 41 | } parents; |
| 42 | |
| 43 | struct { |
| 44 | bool enabled; |
| 45 | int levels[COMPRESSION_ALGORITHM_MAX]; |
| 46 | } compression; |
| 47 | }; |
| 48 | extern struct _stream_send stream_send; |
| 49 | |
| 50 | struct _stream_receive { |
| 51 | struct { |
| 52 | bool enabled; |
| 53 | time_t period; |
| 54 | time_t step; |
| 55 | } replication; |
| 56 | }; |
| 57 | extern struct _stream_receive stream_receive; |
| 58 | |
| 59 | struct stream_receiver_config { |
| 60 | RRD_DB_MODE mode; |
| 61 | int history; |
| 62 | int update_every; |
| 63 | |
| 64 | struct { |
| 65 | bool enabled; // enable replication on this child |
| 66 | time_t period; |
| 67 | time_t step; |
| 68 | } replication; |
| 69 | |
| 70 | struct { |
| 71 | int enabled; // CONFIG_BOOLEAN_YES, CONFIG_BOOLEAN_NO, CONFIG_BOOLEAN_AUTO |
| 72 | time_t delay; |
| 73 | uint32_t history; |
| 74 | } health; |
| 75 | |
| 76 | struct { |
| 77 | bool enabled; |
| 78 | STRING *api_key; |
| 79 | STRING *parents; |
| 80 | STRING *charts_matching; |
| 81 | } send; |
| 82 | |
| 83 | struct { |
| 84 | bool enabled; |
| 85 | STREAM_CAPABILITIES priorities[COMPRESSION_ALGORITHM_MAX]; |
| 86 | } compression; |
| 87 | }; |
| 88 | |
| 89 | void stream_conf_receiver_config(struct receiver_state *rpt, struct stream_receiver_config *config, const char *api_key, const char *machine_guid); |
| 90 | |
| 91 | void stream_conf_load(); |
| 92 | bool stream_conf_receiver_needs_dbengine(); |
| 93 | bool stream_conf_is_parent(bool recheck); |
| 94 | bool stream_conf_is_child(void); |
| 95 | |
| 96 | bool stream_conf_is_key_type(const char *api_key, const char *type); |
| 97 | bool stream_conf_api_key_is_enabled(const char *api_key, bool enabled); |
| 98 | bool stream_conf_api_key_allows_client(const char *api_key, const char *client_ip); |
| 99 | |
| 100 | void stream_conf_set_sender_compression_levels(ND_COMPRESSION_PROFILE profile); |
| 101 | |
| 102 | /** |
| 103 | * Free stream configuration |
| 104 | * |
| 105 | * Free all memory associated with the stream configuration. |
| 106 | * Called during shutdown to prevent memory leaks. |
| 107 | */ |
| 108 | void stream_config_free(void); |
| 109 | |
| 110 | #endif //NETDATA_STREAM_CONF_H |