master
h 137 lines 3.93 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_RRD_H
4 #define NETDATA_RRD_H 1
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 #include "libnetdata/libnetdata.h"
11 #include "rrd-metadata.h"
12
13 // --------------------------------------------------------------------------------------------------------------------
14
15 struct ml_metrics_statistics {
16 size_t anomalous;
17 size_t normal;
18 size_t trained;
19 size_t pending;
20 size_t silenced;
21 };
22
23 // --------------------------------------------------------------------------------------------------------------------
24
25 typedef enum __attribute__ ((__packed__)) {
26 QUERY_SOURCE_UNKNOWN = 0,
27 QUERY_SOURCE_API_DATA,
28 QUERY_SOURCE_API_BADGE,
29 QUERY_SOURCE_API_WEIGHTS,
30 QUERY_SOURCE_HEALTH,
31 QUERY_SOURCE_ML,
32 QUERY_SOURCE_UNITTEST,
33 } QUERY_SOURCE;
34
35 // --------------------------------------------------------------------------------------------------------------------
36
37 typedef struct rrdcalc RRDCALC;
38 typedef struct alarm_entry ALARM_ENTRY;
39 typedef struct rrdvar_acquired RRDVAR_ACQUIRED;
40 typedef struct rrdcalc_acquired RRDCALC_ACQUIRED;
41
42 #ifdef ENABLE_DBENGINE
43 struct rrdengine_instance;
44 #endif
45
46 // --------------------------------------------------------------------------------------------------------------------
47
48 #define UPDATE_EVERY_MIN 1
49 #define UPDATE_EVERY_MAX 3600
50 #define RRD_ID_LENGTH_MAX 1200
51
52 #define RRD_DEFAULT_HISTORY_ENTRIES 3600
53 #define RRD_HISTORY_ENTRIES_MAX (86400*365)
54
55 #if defined(ENV32BIT)
56 #define MIN_LIBUV_WORKER_THREADS 8
57 #define MAX_LIBUV_WORKER_THREADS 128
58 #define RESERVED_LIBUV_WORKER_THREADS 3
59 #else
60 #define MIN_LIBUV_WORKER_THREADS 16
61 #define MAX_LIBUV_WORKER_THREADS 1024
62 #define RESERVED_LIBUV_WORKER_THREADS 6
63 #endif
64
65 extern int libuv_worker_threads;
66 extern bool ieee754_doubles;
67
68 typedef long long total_number;
69
70 // --------------------------------------------------------------------------------------------------------------------
71 // global lock for all RRDHOSTs
72
73 extern netdata_rwlock_t rrd_rwlock;
74
75 #define rrd_rdlock() netdata_rwlock_rdlock(&rrd_rwlock)
76 #define rrd_wrlock() netdata_rwlock_wrlock(&rrd_rwlock)
77 #define rrd_rdunlock() netdata_rwlock_rdunlock(&rrd_rwlock)
78 #define rrd_wrunlock() netdata_rwlock_wrunlock(&rrd_rwlock)
79
80 // --------------------------------------------------------------------------------------------------------------------
81
82 STRING *rrd_string_strdupz(const char *s);
83
84 #include "rrd-database-mode.h"
85 long align_entries_to_pagesize(RRD_DB_MODE mode, long entries);
86
87 static inline uint32_t get_uint32_id() {
88 return now_realtime_sec() & UINT32_MAX;
89 }
90
91 // --------------------------------------------------------------------------------------------------------------------
92
93 #include "storage-engine.h"
94
95 #include "rrdhost.h"
96 #include "rrdset.h"
97 #include "rrddim.h"
98 #include "rrddim-backfill.h"
99
100 #include "streaming/stream-sender-commit.h"
101 #include "streaming/stream-replication-tracking.h"
102 #include "rrdhost-system-info.h"
103 #include "daemon/common.h"
104 #include "web/api/queries/query.h"
105 #include "web/api/queries/rrdr.h"
106 #include "health/rrdvar.h"
107 #include "health/rrdcalc.h"
108 #include "rrdlabels.h"
109 #include "pattern-array.h"
110 #include "streaming/stream-capabilities.h"
111 #include "streaming/stream-path.h"
112 #include "streaming/stream.h"
113 //#include "aclk/aclk_rrdhost_state.h"
114 #include "sqlite/sqlite_health.h"
115 #include "contexts/rrdcontext.h"
116 #include "rrdcollector.h"
117 #include "rrdfunctions.h"
118 #ifdef ENABLE_DBENGINE
119 #include "database/engine/rrdengineapi.h"
120 #endif
121 #include "sqlite/sqlite_functions.h"
122 #include "sqlite/sqlite_context.h"
123 #include "sqlite/sqlite_metadata.h"
124 #include "sqlite/sqlite_aclk.h"
125 #include "sqlite/sqlite_aclk_alert.h"
126 #include "sqlite/sqlite_aclk_node.h"
127 #include "sqlite/sqlite_health.h"
128
129 // --------------------------------------------------------------------------------------------------------------------
130
131 int rrd_init(const char *hostname, struct rrdhost_system_info *system_info, bool unittest);
132
133 #ifdef __cplusplus
134 }
135 #endif
136
137 #endif /* NETDATA_RRD_H */