rrd.h 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_RRD_H
  3. #define NETDATA_RRD_H 1
  4. // forward typedefs
  5. typedef struct rrdhost RRDHOST;
  6. typedef struct rrddim RRDDIM;
  7. typedef struct rrdset RRDSET;
  8. typedef struct rrdvar RRDVAR;
  9. typedef struct rrdsetvar RRDSETVAR;
  10. typedef struct rrddimvar RRDDIMVAR;
  11. typedef struct rrdcalc RRDCALC;
  12. typedef struct rrdcalctemplate RRDCALCTEMPLATE;
  13. typedef struct alarm_entry ALARM_ENTRY;
  14. // forward declarations
  15. struct rrddim_volatile;
  16. #ifdef ENABLE_DBENGINE
  17. struct rrdeng_page_cache_descr;
  18. struct rrdengine_instance;
  19. struct pg_cache_page_index;
  20. #endif
  21. #include "../daemon/common.h"
  22. #include "web/api/queries/query.h"
  23. #include "rrdvar.h"
  24. #include "rrdsetvar.h"
  25. #include "rrddimvar.h"
  26. #include "rrdcalc.h"
  27. #include "rrdcalctemplate.h"
  28. #define UPDATE_EVERY 1
  29. #define UPDATE_EVERY_MAX 3600
  30. #define RRD_DEFAULT_HISTORY_ENTRIES 3600
  31. #define RRD_HISTORY_ENTRIES_MAX (86400*365)
  32. extern int default_rrd_update_every;
  33. extern int default_rrd_history_entries;
  34. extern int gap_when_lost_iterations_above;
  35. extern time_t rrdset_free_obsolete_time;
  36. #define RRD_ID_LENGTH_MAX 200
  37. #define RRDSET_MAGIC "NETDATA RRD SET FILE V019"
  38. #define RRDDIMENSION_MAGIC "NETDATA RRD DIMENSION FILE V019"
  39. typedef long long total_number;
  40. #define TOTAL_NUMBER_FORMAT "%lld"
  41. // ----------------------------------------------------------------------------
  42. // chart types
  43. typedef enum rrdset_type {
  44. RRDSET_TYPE_LINE = 0,
  45. RRDSET_TYPE_AREA = 1,
  46. RRDSET_TYPE_STACKED = 2
  47. } RRDSET_TYPE;
  48. #define RRDSET_TYPE_LINE_NAME "line"
  49. #define RRDSET_TYPE_AREA_NAME "area"
  50. #define RRDSET_TYPE_STACKED_NAME "stacked"
  51. RRDSET_TYPE rrdset_type_id(const char *name);
  52. const char *rrdset_type_name(RRDSET_TYPE chart_type);
  53. // ----------------------------------------------------------------------------
  54. // memory mode
  55. typedef enum rrd_memory_mode {
  56. RRD_MEMORY_MODE_NONE = 0,
  57. RRD_MEMORY_MODE_RAM = 1,
  58. RRD_MEMORY_MODE_MAP = 2,
  59. RRD_MEMORY_MODE_SAVE = 3,
  60. RRD_MEMORY_MODE_ALLOC = 4,
  61. RRD_MEMORY_MODE_DBENGINE = 5
  62. } RRD_MEMORY_MODE;
  63. #define RRD_MEMORY_MODE_NONE_NAME "none"
  64. #define RRD_MEMORY_MODE_RAM_NAME "ram"
  65. #define RRD_MEMORY_MODE_MAP_NAME "map"
  66. #define RRD_MEMORY_MODE_SAVE_NAME "save"
  67. #define RRD_MEMORY_MODE_ALLOC_NAME "alloc"
  68. #define RRD_MEMORY_MODE_DBENGINE_NAME "dbengine"
  69. extern RRD_MEMORY_MODE default_rrd_memory_mode;
  70. extern const char *rrd_memory_mode_name(RRD_MEMORY_MODE id);
  71. extern RRD_MEMORY_MODE rrd_memory_mode_id(const char *name);
  72. // ----------------------------------------------------------------------------
  73. // algorithms types
  74. typedef enum rrd_algorithm {
  75. RRD_ALGORITHM_ABSOLUTE = 0,
  76. RRD_ALGORITHM_INCREMENTAL = 1,
  77. RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL = 2,
  78. RRD_ALGORITHM_PCENT_OVER_ROW_TOTAL = 3
  79. } RRD_ALGORITHM;
  80. #define RRD_ALGORITHM_ABSOLUTE_NAME "absolute"
  81. #define RRD_ALGORITHM_INCREMENTAL_NAME "incremental"
  82. #define RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL_NAME "percentage-of-incremental-row"
  83. #define RRD_ALGORITHM_PCENT_OVER_ROW_TOTAL_NAME "percentage-of-absolute-row"
  84. extern RRD_ALGORITHM rrd_algorithm_id(const char *name);
  85. extern const char *rrd_algorithm_name(RRD_ALGORITHM algorithm);
  86. // ----------------------------------------------------------------------------
  87. // RRD FAMILY
  88. struct rrdfamily {
  89. avl avl;
  90. const char *family;
  91. uint32_t hash_family;
  92. size_t use_count;
  93. avl_tree_lock rrdvar_root_index;
  94. };
  95. typedef struct rrdfamily RRDFAMILY;
  96. // ----------------------------------------------------------------------------
  97. // flags
  98. // use this for configuration flags, not for state control
  99. // flags are set/unset in a manner that is not thread safe
  100. // and may lead to missing information.
  101. typedef enum rrddim_flags {
  102. RRDDIM_FLAG_NONE = 0,
  103. RRDDIM_FLAG_HIDDEN = (1 << 0), // this dimension will not be offered to callers
  104. RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS = (1 << 1), // do not offer RESET or OVERFLOW info to callers
  105. RRDDIM_FLAG_OBSOLETE = (1 << 2) // this is marked by the collector/module as obsolete
  106. } RRDDIM_FLAGS;
  107. #ifdef HAVE_C___ATOMIC
  108. #define rrddim_flag_check(rd, flag) (__atomic_load_n(&((rd)->flags), __ATOMIC_SEQ_CST) & (flag))
  109. #define rrddim_flag_set(rd, flag) __atomic_or_fetch(&((rd)->flags), (flag), __ATOMIC_SEQ_CST)
  110. #define rrddim_flag_clear(rd, flag) __atomic_and_fetch(&((rd)->flags), ~(flag), __ATOMIC_SEQ_CST)
  111. #else
  112. #define rrddim_flag_check(rd, flag) ((rd)->flags & (flag))
  113. #define rrddim_flag_set(rd, flag) (rd)->flags |= (flag)
  114. #define rrddim_flag_clear(rd, flag) (rd)->flags &= ~(flag)
  115. #endif
  116. // ----------------------------------------------------------------------------
  117. // RRD DIMENSION - this is a metric
  118. struct rrddim {
  119. // ------------------------------------------------------------------------
  120. // binary indexing structures
  121. avl avl; // the binary index - this has to be first member!
  122. // ------------------------------------------------------------------------
  123. // the dimension definition
  124. const char *id; // the id of this dimension (for internal identification)
  125. const char *name; // the name of this dimension (as presented to user)
  126. // this is a pointer to the config structure
  127. // since the config always has a higher priority
  128. // (the user overwrites the name of the charts)
  129. // DO NOT FREE THIS - IT IS ALLOCATED IN CONFIG
  130. RRD_ALGORITHM algorithm; // the algorithm that is applied to add new collected values
  131. RRD_MEMORY_MODE rrd_memory_mode; // the memory mode for this dimension
  132. collected_number multiplier; // the multiplier of the collected values
  133. collected_number divisor; // the divider of the collected values
  134. uint32_t flags; // configuration flags for the dimension
  135. // ------------------------------------------------------------------------
  136. // members for temporary data we need for calculations
  137. uint32_t hash; // a simple hash of the id, to speed up searching / indexing
  138. // instead of strcmp() every item in the binary index
  139. // we first compare the hashes
  140. uint32_t hash_name; // a simple hash of the name
  141. char *cache_filename; // the filename we load/save from/to this set
  142. size_t collections_counter; // the number of times we added values to this rrdim
  143. struct rrddim_volatile *state; // volatile state that is not persistently stored
  144. size_t unused[8];
  145. collected_number collected_value_max; // the absolute maximum of the collected value
  146. unsigned int updated:1; // 1 when the dimension has been updated since the last processing
  147. unsigned int exposed:1; // 1 when set what have sent this dimension to the central netdata
  148. struct timeval last_collected_time; // when was this dimension last updated
  149. // this is actual date time we updated the last_collected_value
  150. // THIS IS DIFFERENT FROM THE SAME MEMBER OF RRDSET
  151. calculated_number calculated_value; // the current calculated value, after applying the algorithm - resets to zero after being used
  152. calculated_number last_calculated_value; // the last calculated value processed
  153. calculated_number last_stored_value; // the last value as stored in the database (after interpolation)
  154. collected_number collected_value; // the current value, as collected - resets to 0 after being used
  155. collected_number last_collected_value; // the last value that was collected, after being processed
  156. // the *_volume members are used to calculate the accuracy of the rounding done by the
  157. // storage number - they are printed to debug.log when debug is enabled for a set.
  158. calculated_number collected_volume; // the sum of all collected values so far
  159. calculated_number stored_volume; // the sum of all stored values so far
  160. struct rrddim *next; // linking of dimensions within the same data set
  161. struct rrdset *rrdset;
  162. // ------------------------------------------------------------------------
  163. // members for checking the data when loading from disk
  164. long entries; // how many entries this dimension has in ram
  165. // this is the same to the entries of the data set
  166. // we set it here, to check the data when we load it from disk.
  167. int update_every; // every how many seconds is this updated
  168. size_t memsize; // the memory allocated for this dimension
  169. char magic[sizeof(RRDDIMENSION_MAGIC) + 1]; // a string to be saved, used to identify our data file
  170. struct rrddimvar *variables;
  171. // ------------------------------------------------------------------------
  172. // the values stored in this dimension, using our floating point numbers
  173. storage_number values[]; // the array of values - THIS HAS TO BE THE LAST MEMBER
  174. };
  175. // ----------------------------------------------------------------------------
  176. // iterator state for RRD dimension data collection
  177. union rrddim_collect_handle {
  178. struct {
  179. long slot;
  180. long entries;
  181. } slotted; // state the legacy code uses
  182. #ifdef ENABLE_DBENGINE
  183. struct rrdeng_collect_handle {
  184. struct rrdeng_page_cache_descr *descr, *prev_descr;
  185. unsigned long page_correlation_id;
  186. struct rrdengine_instance *ctx;
  187. struct pg_cache_page_index *page_index;
  188. } rrdeng; // state the database engine uses
  189. #endif
  190. };
  191. // ----------------------------------------------------------------------------
  192. // iterator state for RRD dimension data queries
  193. struct rrddim_query_handle {
  194. RRDDIM *rd;
  195. time_t start_time;
  196. time_t end_time;
  197. union {
  198. struct {
  199. long slot;
  200. long last_slot;
  201. uint8_t finished;
  202. } slotted; // state the legacy code uses
  203. #ifdef ENABLE_DBENGINE
  204. struct rrdeng_query_handle {
  205. struct rrdeng_page_cache_descr *descr;
  206. struct rrdengine_instance *ctx;
  207. struct pg_cache_page_index *page_index;
  208. time_t now; //TODO: remove now to implement next point iteration
  209. time_t dt; //TODO: remove dt to implement next point iteration
  210. } rrdeng; // state the database engine uses
  211. #endif
  212. };
  213. };
  214. // ----------------------------------------------------------------------------
  215. // volatile state per RRD dimension
  216. struct rrddim_volatile {
  217. #ifdef ENABLE_DBENGINE
  218. uuid_t *rrdeng_uuid; // database engine metric UUID
  219. #endif
  220. union rrddim_collect_handle handle;
  221. // ------------------------------------------------------------------------
  222. // function pointers that handle data collection
  223. struct rrddim_collect_ops {
  224. // an initialization function to run before starting collection
  225. void (*init)(RRDDIM *rd);
  226. // run this to store each metric into the database
  227. void (*store_metric)(RRDDIM *rd, usec_t point_in_time, storage_number number);
  228. // an finalization function to run after collection is over
  229. void (*finalize)(RRDDIM *rd);
  230. } collect_ops;
  231. // function pointers that handle database queries
  232. struct rrddim_query_ops {
  233. // run this before starting a series of next_metric() database queries
  234. void (*init)(RRDDIM *rd, struct rrddim_query_handle *handle, time_t start_time, time_t end_time);
  235. // run this to load each metric number from the database
  236. storage_number (*next_metric)(struct rrddim_query_handle *handle);
  237. // run this to test if the series of next_metric() database queries is finished
  238. int (*is_finished)(struct rrddim_query_handle *handle);
  239. // run this after finishing a series of load_metric() database queries
  240. void (*finalize)(struct rrddim_query_handle *handle);
  241. // get the timestamp of the last entry of this metric
  242. time_t (*latest_time)(RRDDIM *rd);
  243. // get the timestamp of the first entry of this metric
  244. time_t (*oldest_time)(RRDDIM *rd);
  245. } query_ops;
  246. };
  247. // ----------------------------------------------------------------------------
  248. // these loop macros make sure the linked list is accessed with the right lock
  249. #define rrddim_foreach_read(rd, st) \
  250. for((rd) = (st)->dimensions, rrdset_check_rdlock(st); (rd) ; (rd) = (rd)->next)
  251. #define rrddim_foreach_write(rd, st) \
  252. for((rd) = (st)->dimensions, rrdset_check_wrlock(st); (rd) ; (rd) = (rd)->next)
  253. // ----------------------------------------------------------------------------
  254. // RRDSET - this is a chart
  255. // use this for configuration flags, not for state control
  256. // flags are set/unset in a manner that is not thread safe
  257. // and may lead to missing information.
  258. typedef enum rrdset_flags {
  259. RRDSET_FLAG_ENABLED = 1 << 0, // enables or disables a chart
  260. RRDSET_FLAG_DETAIL = 1 << 1, // if set, the data set should be considered as a detail of another
  261. // (the master data set should be the one that has the same family and is not detail)
  262. RRDSET_FLAG_DEBUG = 1 << 2, // enables or disables debugging for a chart
  263. RRDSET_FLAG_OBSOLETE = 1 << 3, // this is marked by the collector/module as obsolete
  264. RRDSET_FLAG_BACKEND_SEND = 1 << 4, // if set, this chart should be sent to backends
  265. RRDSET_FLAG_BACKEND_IGNORE = 1 << 5, // if set, this chart should not be sent to backends
  266. RRDSET_FLAG_UPSTREAM_SEND = 1 << 6, // if set, this chart should be sent upstream (streaming)
  267. RRDSET_FLAG_UPSTREAM_IGNORE = 1 << 7, // if set, this chart should not be sent upstream (streaming)
  268. RRDSET_FLAG_UPSTREAM_EXPOSED = 1 << 8, // if set, we have sent this chart definition to netdata master (streaming)
  269. RRDSET_FLAG_STORE_FIRST = 1 << 9, // if set, do not eliminate the first collection during interpolation
  270. RRDSET_FLAG_HETEROGENEOUS = 1 << 10, // if set, the chart is not homogeneous (dimensions in it have multiple algorithms, multipliers or dividers)
  271. RRDSET_FLAG_HOMEGENEOUS_CHECK = 1 << 11, // if set, the chart should be checked to determine if the dimensions as homogeneous
  272. RRDSET_FLAG_HIDDEN = 1 << 12, // if set, do not show this chart on the dashboard, but use it for backends
  273. RRDSET_FLAG_SYNC_CLOCK = 1 << 13, // if set, microseconds on next data collection will be ignored (the chart will be synced to now)
  274. RRDSET_FLAG_OBSOLETE_DIMENSIONS = 1 << 14 // this is marked by the collector/module when a chart has obsolete dimensions
  275. } RRDSET_FLAGS;
  276. #ifdef HAVE_C___ATOMIC
  277. #define rrdset_flag_check(st, flag) (__atomic_load_n(&((st)->flags), __ATOMIC_SEQ_CST) & (flag))
  278. #define rrdset_flag_set(st, flag) __atomic_or_fetch(&((st)->flags), flag, __ATOMIC_SEQ_CST)
  279. #define rrdset_flag_clear(st, flag) __atomic_and_fetch(&((st)->flags), ~flag, __ATOMIC_SEQ_CST)
  280. #else
  281. #define rrdset_flag_check(st, flag) ((st)->flags & (flag))
  282. #define rrdset_flag_set(st, flag) (st)->flags |= (flag)
  283. #define rrdset_flag_clear(st, flag) (st)->flags &= ~(flag)
  284. #endif
  285. #define rrdset_flag_check_noatomic(st, flag) ((st)->flags & (flag))
  286. struct rrdset {
  287. // ------------------------------------------------------------------------
  288. // binary indexing structures
  289. avl avl; // the index, with key the id - this has to be first!
  290. avl avlname; // the index, with key the name
  291. // ------------------------------------------------------------------------
  292. // the set configuration
  293. char id[RRD_ID_LENGTH_MAX + 1]; // id of the data set
  294. const char *name; // the name of this dimension (as presented to user)
  295. // this is a pointer to the config structure
  296. // since the config always has a higher priority
  297. // (the user overwrites the name of the charts)
  298. char *config_section; // the config section for the chart
  299. char *type; // the type of graph RRD_TYPE_* (a category, for determining graphing options)
  300. char *family; // grouping sets under the same family
  301. char *title; // title shown to user
  302. char *units; // units of measurement
  303. char *context; // the template of this data set
  304. uint32_t hash_context; // the hash of the chart's context
  305. RRDSET_TYPE chart_type; // line, area, stacked
  306. int update_every; // every how many seconds is this updated?
  307. long entries; // total number of entries in the data set
  308. long current_entry; // the entry that is currently being updated
  309. // it goes around in a round-robin fashion
  310. RRDSET_FLAGS flags; // configuration flags
  311. int gap_when_lost_iterations_above; // after how many lost iterations a gap should be stored
  312. // netdata will interpolate values for gaps lower than this
  313. long priority; // the sorting priority of this chart
  314. // ------------------------------------------------------------------------
  315. // members for temporary data we need for calculations
  316. RRD_MEMORY_MODE rrd_memory_mode; // if set to 1, this is memory mapped
  317. char *cache_dir; // the directory to store dimensions
  318. char cache_filename[FILENAME_MAX+1]; // the filename to store this set
  319. netdata_rwlock_t rrdset_rwlock; // protects dimensions linked list
  320. size_t counter; // the number of times we added values to this database
  321. size_t counter_done; // the number of times rrdset_done() has been called
  322. time_t last_accessed_time; // the last time this RRDSET has been accessed
  323. time_t upstream_resync_time; // the timestamp up to which we should resync clock upstream
  324. char *plugin_name; // the name of the plugin that generated this
  325. char *module_name; // the name of the plugin module that generated this
  326. size_t unused[6];
  327. uint32_t hash; // a simple hash on the id, to speed up searching
  328. // we first compare hashes, and only if the hashes are equal we do string comparisons
  329. uint32_t hash_name; // a simple hash on the name
  330. usec_t usec_since_last_update; // the time in microseconds since the last collection of data
  331. struct timeval last_updated; // when this data set was last updated (updated every time the rrd_stats_done() function)
  332. struct timeval last_collected_time; // when did this data set last collected values
  333. total_number collected_total; // used internally to calculate percentages
  334. total_number last_collected_total; // used internally to calculate percentages
  335. RRDFAMILY *rrdfamily; // pointer to RRDFAMILY this chart belongs to
  336. RRDHOST *rrdhost; // pointer to RRDHOST this chart belongs to
  337. struct rrdset *next; // linking of rrdsets
  338. // ------------------------------------------------------------------------
  339. // local variables
  340. calculated_number green; // green threshold for this chart
  341. calculated_number red; // red threshold for this chart
  342. avl_tree_lock rrdvar_root_index; // RRDVAR index for this chart
  343. RRDSETVAR *variables; // RRDSETVAR linked list for this chart (one RRDSETVAR, many RRDVARs)
  344. RRDCALC *alarms; // RRDCALC linked list for this chart
  345. // ------------------------------------------------------------------------
  346. // members for checking the data when loading from disk
  347. unsigned long memsize; // how much mem we have allocated for this (without dimensions)
  348. char magic[sizeof(RRDSET_MAGIC) + 1]; // our magic
  349. // ------------------------------------------------------------------------
  350. // the dimensions
  351. avl_tree_lock dimensions_index; // the root of the dimensions index
  352. RRDDIM *dimensions; // the actual data for every dimension
  353. };
  354. #define rrdset_rdlock(st) netdata_rwlock_rdlock(&((st)->rrdset_rwlock))
  355. #define rrdset_wrlock(st) netdata_rwlock_wrlock(&((st)->rrdset_rwlock))
  356. #define rrdset_unlock(st) netdata_rwlock_unlock(&((st)->rrdset_rwlock))
  357. // ----------------------------------------------------------------------------
  358. // these loop macros make sure the linked list is accessed with the right lock
  359. #define rrdset_foreach_read(st, host) \
  360. for((st) = (host)->rrdset_root, rrdhost_check_rdlock(host); st ; (st) = (st)->next)
  361. #define rrdset_foreach_write(st, host) \
  362. for((st) = (host)->rrdset_root, rrdhost_check_wrlock(host); st ; (st) = (st)->next)
  363. // ----------------------------------------------------------------------------
  364. // RRDHOST flags
  365. // use this for configuration flags, not for state control
  366. // flags are set/unset in a manner that is not thread safe
  367. // and may lead to missing information.
  368. typedef enum rrdhost_flags {
  369. RRDHOST_FLAG_ORPHAN = 1 << 0, // this host is orphan (not receiving data)
  370. RRDHOST_FLAG_DELETE_OBSOLETE_CHARTS = 1 << 1, // delete files of obsolete charts
  371. RRDHOST_FLAG_DELETE_ORPHAN_HOST = 1 << 2, // delete the entire host when orphan
  372. RRDHOST_FLAG_BACKEND_SEND = 1 << 3, // send it to backends
  373. RRDHOST_FLAG_BACKEND_DONT_SEND = 1 << 4, // don't send it to backends
  374. } RRDHOST_FLAGS;
  375. #ifdef HAVE_C___ATOMIC
  376. #define rrdhost_flag_check(host, flag) (__atomic_load_n(&((host)->flags), __ATOMIC_SEQ_CST) & (flag))
  377. #define rrdhost_flag_set(host, flag) __atomic_or_fetch(&((host)->flags), flag, __ATOMIC_SEQ_CST)
  378. #define rrdhost_flag_clear(host, flag) __atomic_and_fetch(&((host)->flags), ~flag, __ATOMIC_SEQ_CST)
  379. #else
  380. #define rrdhost_flag_check(host, flag) ((host)->flags & (flag))
  381. #define rrdhost_flag_set(host, flag) (host)->flags |= (flag)
  382. #define rrdhost_flag_clear(host, flag) (host)->flags &= ~(flag)
  383. #endif
  384. #ifdef NETDATA_INTERNAL_CHECKS
  385. #define rrdset_debug(st, fmt, args...) do { if(unlikely(debug_flags & D_RRD_STATS && rrdset_flag_check(st, RRDSET_FLAG_DEBUG))) \
  386. debug_int(__FILE__, __FUNCTION__, __LINE__, "%s: " fmt, st->name, ##args); } while(0)
  387. #else
  388. #define rrdset_debug(st, fmt, args...) debug_dummy()
  389. #endif
  390. // ----------------------------------------------------------------------------
  391. // Health data
  392. struct alarm_entry {
  393. uint32_t unique_id;
  394. uint32_t alarm_id;
  395. uint32_t alarm_event_id;
  396. time_t when;
  397. time_t duration;
  398. time_t non_clear_duration;
  399. char *name;
  400. uint32_t hash_name;
  401. char *chart;
  402. uint32_t hash_chart;
  403. char *family;
  404. char *exec;
  405. char *recipient;
  406. time_t exec_run_timestamp;
  407. int exec_code;
  408. char *source;
  409. char *units;
  410. char *info;
  411. calculated_number old_value;
  412. calculated_number new_value;
  413. char *old_value_string;
  414. char *new_value_string;
  415. RRDCALC_STATUS old_status;
  416. RRDCALC_STATUS new_status;
  417. uint32_t flags;
  418. int delay;
  419. time_t delay_up_to_timestamp;
  420. uint32_t updated_by_id;
  421. uint32_t updates_id;
  422. struct alarm_entry *next;
  423. };
  424. typedef struct alarm_log {
  425. uint32_t next_log_id;
  426. uint32_t next_alarm_id;
  427. unsigned int count;
  428. unsigned int max;
  429. ALARM_ENTRY *alarms;
  430. netdata_rwlock_t alarm_log_rwlock;
  431. } ALARM_LOG;
  432. // ----------------------------------------------------------------------------
  433. // RRD HOST
  434. struct rrdhost_system_info {
  435. char *os_name;
  436. char *os_id;
  437. char *os_id_like;
  438. char *os_version;
  439. char *os_version_id;
  440. char *os_detection;
  441. char *kernel_name;
  442. char *kernel_version;
  443. char *architecture;
  444. char *virtualization;
  445. char *virt_detection;
  446. char *container;
  447. char *container_detection;
  448. };
  449. struct rrdhost {
  450. avl avl; // the index of hosts
  451. // ------------------------------------------------------------------------
  452. // host information
  453. char *hostname; // the hostname of this host
  454. uint32_t hash_hostname; // the hostname hash
  455. char *registry_hostname; // the registry hostname for this host
  456. char machine_guid[GUID_LEN + 1]; // the unique ID of this host
  457. uint32_t hash_machine_guid; // the hash of the unique ID
  458. const char *os; // the O/S type of the host
  459. const char *tags; // tags for this host
  460. const char *timezone; // the timezone of the host
  461. RRDHOST_FLAGS flags; // flags about this RRDHOST
  462. int rrd_update_every; // the update frequency of the host
  463. long rrd_history_entries; // the number of history entries for the host's charts
  464. #ifdef ENABLE_DBENGINE
  465. unsigned page_cache_mb; // Database Engine page cache size in MiB
  466. unsigned disk_space_mb; // Database Engine disk space quota in MiB
  467. #endif
  468. RRD_MEMORY_MODE rrd_memory_mode; // the memory more for the charts of this host
  469. char *cache_dir; // the directory to save RRD cache files
  470. char *varlib_dir; // the directory to save health log
  471. char *program_name; // the program name that collects metrics for this host
  472. char *program_version; // the program version that collects metrics for this host
  473. struct rrdhost_system_info *system_info; // information collected from the host environment
  474. // ------------------------------------------------------------------------
  475. // streaming of data to remote hosts - rrdpush
  476. unsigned int rrdpush_send_enabled:1; // 1 when this host sends metrics to another netdata
  477. char *rrdpush_send_destination; // where to send metrics to
  478. char *rrdpush_send_api_key; // the api key at the receiving netdata
  479. // the following are state information for the threading
  480. // streaming metrics from this netdata to an upstream netdata
  481. volatile unsigned int rrdpush_sender_spawn:1; // 1 when the sender thread has been spawn
  482. netdata_thread_t rrdpush_sender_thread; // the sender thread
  483. volatile unsigned int rrdpush_sender_connected:1; // 1 when the sender is ready to push metrics
  484. int rrdpush_sender_socket; // the fd of the socket to the remote host, or -1
  485. volatile unsigned int rrdpush_sender_error_shown:1; // 1 when we have logged a communication error
  486. volatile unsigned int rrdpush_sender_join:1; // 1 when we have to join the sending thread
  487. SIMPLE_PATTERN *rrdpush_send_charts_matching; // pattern to match the charts to be sent
  488. // metrics may be collected asynchronously
  489. // these synchronize all the threads willing the write to our sending buffer
  490. netdata_mutex_t rrdpush_sender_buffer_mutex; // exclusive access to rrdpush_sender_buffer
  491. int rrdpush_sender_pipe[2]; // collector to sender thread signaling
  492. BUFFER *rrdpush_sender_buffer; // collector fills it, sender sends it
  493. // ------------------------------------------------------------------------
  494. // streaming of data from remote hosts - rrdpush
  495. volatile size_t connected_senders; // when remote hosts are streaming to this
  496. // host, this is the counter of connected clients
  497. time_t senders_disconnected_time; // the time the last sender was disconnected
  498. // ------------------------------------------------------------------------
  499. // health monitoring options
  500. unsigned int health_enabled:1; // 1 when this host has health enabled
  501. time_t health_delay_up_to; // a timestamp to delay alarms processing up to
  502. char *health_default_exec; // the full path of the alarms notifications program
  503. char *health_default_recipient; // the default recipient for all alarms
  504. char *health_log_filename; // the alarms event log filename
  505. size_t health_log_entries_written; // the number of alarm events writtern to the alarms event log
  506. FILE *health_log_fp; // the FILE pointer to the open alarms event log file
  507. // all RRDCALCs are primarily allocated and linked here
  508. // RRDCALCs may be linked to charts at any point
  509. // (charts may or may not exist when these are loaded)
  510. RRDCALC *alarms;
  511. ALARM_LOG health_log; // alarms historical events (event log)
  512. uint32_t health_last_processed_id; // the last processed health id from the log
  513. uint32_t health_max_unique_id; // the max alarm log unique id given for the host
  514. uint32_t health_max_alarm_id; // the max alarm id given for the host
  515. // templates of alarms
  516. // these are used to create alarms when charts
  517. // are created or renamed, that match them
  518. RRDCALCTEMPLATE *templates;
  519. // ------------------------------------------------------------------------
  520. // the charts of the host
  521. RRDSET *rrdset_root; // the host charts
  522. // ------------------------------------------------------------------------
  523. // locks
  524. netdata_rwlock_t rrdhost_rwlock; // lock for this RRDHOST (protects rrdset_root linked list)
  525. // ------------------------------------------------------------------------
  526. // indexes
  527. avl_tree_lock rrdset_root_index; // the host's charts index (by id)
  528. avl_tree_lock rrdset_root_index_name; // the host's charts index (by name)
  529. avl_tree_lock rrdfamily_root_index; // the host's chart families index
  530. avl_tree_lock rrdvar_root_index; // the host's chart variables index
  531. #ifdef ENABLE_DBENGINE
  532. struct rrdengine_instance *rrdeng_ctx; // DB engine instance for this host
  533. #endif
  534. struct rrdhost *next;
  535. };
  536. extern RRDHOST *localhost;
  537. #define rrdhost_rdlock(host) netdata_rwlock_rdlock(&((host)->rrdhost_rwlock))
  538. #define rrdhost_wrlock(host) netdata_rwlock_wrlock(&((host)->rrdhost_rwlock))
  539. #define rrdhost_unlock(host) netdata_rwlock_unlock(&((host)->rrdhost_rwlock))
  540. // ----------------------------------------------------------------------------
  541. // these loop macros make sure the linked list is accessed with the right lock
  542. #define rrdhost_foreach_read(var) \
  543. for((var) = localhost, rrd_check_rdlock(); var ; (var) = (var)->next)
  544. #define rrdhost_foreach_write(var) \
  545. for((var) = localhost, rrd_check_wrlock(); var ; (var) = (var)->next)
  546. // ----------------------------------------------------------------------------
  547. // global lock for all RRDHOSTs
  548. extern netdata_rwlock_t rrd_rwlock;
  549. #define rrd_rdlock() netdata_rwlock_rdlock(&rrd_rwlock)
  550. #define rrd_wrlock() netdata_rwlock_wrlock(&rrd_rwlock)
  551. #define rrd_unlock() netdata_rwlock_unlock(&rrd_rwlock)
  552. // ----------------------------------------------------------------------------
  553. extern size_t rrd_hosts_available;
  554. extern time_t rrdhost_free_orphan_time;
  555. extern void rrd_init(char *hostname, struct rrdhost_system_info *system_info);
  556. extern RRDHOST *rrdhost_find_by_hostname(const char *hostname, uint32_t hash);
  557. extern RRDHOST *rrdhost_find_by_guid(const char *guid, uint32_t hash);
  558. extern RRDHOST *rrdhost_find_or_create(
  559. const char *hostname
  560. , const char *registry_hostname
  561. , const char *guid
  562. , const char *os
  563. , const char *timezone
  564. , const char *tags
  565. , const char *program_name
  566. , const char *program_version
  567. , int update_every
  568. , long history
  569. , RRD_MEMORY_MODE mode
  570. , unsigned int health_enabled
  571. , unsigned int rrdpush_enabled
  572. , char *rrdpush_destination
  573. , char *rrdpush_api_key
  574. , char *rrdpush_send_charts_matching
  575. , struct rrdhost_system_info *system_info
  576. );
  577. extern int rrdhost_set_system_info_variable(struct rrdhost_system_info *system_info, char *name, char *value);
  578. #if defined(NETDATA_INTERNAL_CHECKS) && defined(NETDATA_VERIFY_LOCKS)
  579. extern void __rrdhost_check_wrlock(RRDHOST *host, const char *file, const char *function, const unsigned long line);
  580. extern void __rrdhost_check_rdlock(RRDHOST *host, const char *file, const char *function, const unsigned long line);
  581. extern void __rrdset_check_rdlock(RRDSET *st, const char *file, const char *function, const unsigned long line);
  582. extern void __rrdset_check_wrlock(RRDSET *st, const char *file, const char *function, const unsigned long line);
  583. extern void __rrd_check_rdlock(const char *file, const char *function, const unsigned long line);
  584. extern void __rrd_check_wrlock(const char *file, const char *function, const unsigned long line);
  585. #define rrdhost_check_rdlock(host) __rrdhost_check_rdlock(host, __FILE__, __FUNCTION__, __LINE__)
  586. #define rrdhost_check_wrlock(host) __rrdhost_check_wrlock(host, __FILE__, __FUNCTION__, __LINE__)
  587. #define rrdset_check_rdlock(st) __rrdset_check_rdlock(st, __FILE__, __FUNCTION__, __LINE__)
  588. #define rrdset_check_wrlock(st) __rrdset_check_wrlock(st, __FILE__, __FUNCTION__, __LINE__)
  589. #define rrd_check_rdlock() __rrd_check_rdlock(__FILE__, __FUNCTION__, __LINE__)
  590. #define rrd_check_wrlock() __rrd_check_wrlock(__FILE__, __FUNCTION__, __LINE__)
  591. #else
  592. #define rrdhost_check_rdlock(host) (void)0
  593. #define rrdhost_check_wrlock(host) (void)0
  594. #define rrdset_check_rdlock(st) (void)0
  595. #define rrdset_check_wrlock(st) (void)0
  596. #define rrd_check_rdlock() (void)0
  597. #define rrd_check_wrlock() (void)0
  598. #endif
  599. // ----------------------------------------------------------------------------
  600. // RRDSET functions
  601. extern int rrdset_set_name(RRDSET *st, const char *name);
  602. extern RRDSET *rrdset_create_custom(RRDHOST *host
  603. , const char *type
  604. , const char *id
  605. , const char *name
  606. , const char *family
  607. , const char *context
  608. , const char *title
  609. , const char *units
  610. , const char *plugin
  611. , const char *module
  612. , long priority
  613. , int update_every
  614. , RRDSET_TYPE chart_type
  615. , RRD_MEMORY_MODE memory_mode
  616. , long history_entries);
  617. #define rrdset_create(host, type, id, name, family, context, title, units, plugin, module, priority, update_every, chart_type) \
  618. rrdset_create_custom(host, type, id, name, family, context, title, units, plugin, module, priority, update_every, chart_type, (host)->rrd_memory_mode, (host)->rrd_history_entries)
  619. #define rrdset_create_localhost(type, id, name, family, context, title, units, plugin, module, priority, update_every, chart_type) \
  620. rrdset_create(localhost, type, id, name, family, context, title, units, plugin, module, priority, update_every, chart_type)
  621. extern void rrdhost_free_all(void);
  622. extern void rrdhost_save_all(void);
  623. extern void rrdhost_cleanup_all(void);
  624. extern void rrdhost_cleanup_orphan_hosts_nolock(RRDHOST *protected);
  625. extern void rrdhost_system_info_free(struct rrdhost_system_info *system_info);
  626. extern void rrdhost_free(RRDHOST *host);
  627. extern void rrdhost_save_charts(RRDHOST *host);
  628. extern void rrdhost_delete_charts(RRDHOST *host);
  629. extern int rrdhost_should_be_removed(RRDHOST *host, RRDHOST *protected, time_t now);
  630. extern void rrdset_update_heterogeneous_flag(RRDSET *st);
  631. extern RRDSET *rrdset_find(RRDHOST *host, const char *id);
  632. #define rrdset_find_localhost(id) rrdset_find(localhost, id)
  633. extern RRDSET *rrdset_find_bytype(RRDHOST *host, const char *type, const char *id);
  634. #define rrdset_find_bytype_localhost(type, id) rrdset_find_bytype(localhost, type, id)
  635. extern RRDSET *rrdset_find_byname(RRDHOST *host, const char *name);
  636. #define rrdset_find_byname_localhost(name) rrdset_find_byname(localhost, name)
  637. extern void rrdset_next_usec_unfiltered(RRDSET *st, usec_t microseconds);
  638. extern void rrdset_next_usec(RRDSET *st, usec_t microseconds);
  639. #define rrdset_next(st) rrdset_next_usec(st, 0ULL)
  640. extern void rrdset_done(RRDSET *st);
  641. extern void rrdset_is_obsolete(RRDSET *st);
  642. extern void rrdset_isnot_obsolete(RRDSET *st);
  643. // checks if the RRDSET should be offered to viewers
  644. #define rrdset_is_available_for_viewers(st) (rrdset_flag_check(st, RRDSET_FLAG_ENABLED) && !rrdset_flag_check(st, RRDSET_FLAG_HIDDEN) && !rrdset_flag_check(st, RRDSET_FLAG_OBSOLETE) && (st)->dimensions && (st)->rrd_memory_mode != RRD_MEMORY_MODE_NONE)
  645. #define rrdset_is_available_for_backends(st) (rrdset_flag_check(st, RRDSET_FLAG_ENABLED) && !rrdset_flag_check(st, RRDSET_FLAG_OBSOLETE) && (st)->dimensions)
  646. // get the total duration in seconds of the round robin database
  647. #define rrdset_duration(st) ((time_t)( (((st)->counter >= ((unsigned long)(st)->entries))?(unsigned long)(st)->entries:(st)->counter) * (st)->update_every ))
  648. // get the timestamp of the last entry in the round robin database
  649. static inline time_t rrdset_last_entry_t(RRDSET *st) {
  650. if (st->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE) {
  651. RRDDIM *rd;
  652. time_t last_entry_t = 0;
  653. int ret = netdata_rwlock_tryrdlock(&st->rrdset_rwlock);
  654. rrddim_foreach_read(rd, st) {
  655. last_entry_t = MAX(last_entry_t, rd->state->query_ops.latest_time(rd));
  656. }
  657. if(0 == ret) netdata_rwlock_unlock(&st->rrdset_rwlock);
  658. return last_entry_t;
  659. } else {
  660. return (time_t)st->last_updated.tv_sec;
  661. }
  662. }
  663. // get the timestamp of first entry in the round robin database
  664. static inline time_t rrdset_first_entry_t(RRDSET *st) {
  665. if (st->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE) {
  666. RRDDIM *rd;
  667. time_t first_entry_t = LONG_MAX;
  668. int ret = netdata_rwlock_tryrdlock(&st->rrdset_rwlock);
  669. rrddim_foreach_read(rd, st) {
  670. first_entry_t = MIN(first_entry_t, rd->state->query_ops.oldest_time(rd));
  671. }
  672. if(0 == ret) netdata_rwlock_unlock(&st->rrdset_rwlock);
  673. if (unlikely(LONG_MAX == first_entry_t)) return 0;
  674. return first_entry_t;
  675. } else {
  676. return (time_t)(rrdset_last_entry_t(st) - rrdset_duration(st));
  677. }
  678. }
  679. // get the last slot updated in the round robin database
  680. #define rrdset_last_slot(st) ((size_t)(((st)->current_entry == 0) ? (st)->entries - 1 : (st)->current_entry - 1))
  681. // get the first / oldest slot updated in the round robin database
  682. // #define rrdset_first_slot(st) ((size_t)( (((st)->counter >= ((unsigned long)(st)->entries)) ? (unsigned long)( ((unsigned long)(st)->current_entry > 0) ? ((unsigned long)(st)->current_entry) : ((unsigned long)(st)->entries) ) - 1 : 0) ))
  683. // return the slot that has the oldest value
  684. static inline size_t rrdset_first_slot(RRDSET *st) {
  685. if(st->counter >= (size_t)st->entries) {
  686. // the database has been rotated at least once
  687. // the oldest entry is the one that will be next
  688. // overwritten by data collection
  689. return (size_t)st->current_entry;
  690. }
  691. // we do not have rotated the db yet
  692. // so 0 is the first entry
  693. return 0;
  694. }
  695. // get the slot of the round robin database, for the given timestamp (t)
  696. // it always returns a valid slot, although may not be for the time requested if the time is outside the round robin database
  697. static inline size_t rrdset_time2slot(RRDSET *st, time_t t) {
  698. size_t ret = 0;
  699. if(t >= rrdset_last_entry_t(st)) {
  700. // the requested time is after the last entry we have
  701. ret = rrdset_last_slot(st);
  702. }
  703. else {
  704. if(t <= rrdset_first_entry_t(st)) {
  705. // the requested time is before the first entry we have
  706. ret = rrdset_first_slot(st);
  707. }
  708. else {
  709. if(rrdset_last_slot(st) >= ((rrdset_last_entry_t(st) - t) / (size_t)(st->update_every)))
  710. ret = rrdset_last_slot(st) - ((rrdset_last_entry_t(st) - t) / (size_t)(st->update_every));
  711. else
  712. ret = rrdset_last_slot(st) - ((rrdset_last_entry_t(st) - t) / (size_t)(st->update_every)) + (unsigned long)st->entries;
  713. }
  714. }
  715. if(unlikely(ret >= (size_t)st->entries)) {
  716. error("INTERNAL ERROR: rrdset_time2slot() on %s returns values outside entries", st->name);
  717. ret = (size_t)(st->entries - 1);
  718. }
  719. return ret;
  720. }
  721. // get the timestamp of a specific slot in the round robin database
  722. static inline time_t rrdset_slot2time(RRDSET *st, size_t slot) {
  723. time_t ret;
  724. if(slot >= (size_t)st->entries) {
  725. error("INTERNAL ERROR: caller of rrdset_slot2time() gives invalid slot %zu", slot);
  726. slot = (size_t)st->entries - 1;
  727. }
  728. if(slot > rrdset_last_slot(st)) {
  729. ret = rrdset_last_entry_t(st) - (size_t)st->update_every * (rrdset_last_slot(st) - slot + (size_t)st->entries);
  730. }
  731. else {
  732. ret = rrdset_last_entry_t(st) - (size_t)st->update_every;
  733. }
  734. if(unlikely(ret < rrdset_first_entry_t(st))) {
  735. error("INTERNAL ERROR: rrdset_slot2time() on %s returns time too far in the past", st->name);
  736. ret = rrdset_first_entry_t(st);
  737. }
  738. if(unlikely(ret > rrdset_last_entry_t(st))) {
  739. error("INTERNAL ERROR: rrdset_slot2time() on %s returns time into the future", st->name);
  740. ret = rrdset_last_entry_t(st);
  741. }
  742. return ret;
  743. }
  744. // ----------------------------------------------------------------------------
  745. // RRD DIMENSION functions
  746. extern RRDDIM *rrddim_add_custom(RRDSET *st, const char *id, const char *name, collected_number multiplier, collected_number divisor, RRD_ALGORITHM algorithm, RRD_MEMORY_MODE memory_mode);
  747. #define rrddim_add(st, id, name, multiplier, divisor, algorithm) rrddim_add_custom(st, id, name, multiplier, divisor, algorithm, (st)->rrd_memory_mode)
  748. extern int rrddim_set_name(RRDSET *st, RRDDIM *rd, const char *name);
  749. extern int rrddim_set_algorithm(RRDSET *st, RRDDIM *rd, RRD_ALGORITHM algorithm);
  750. extern int rrddim_set_multiplier(RRDSET *st, RRDDIM *rd, collected_number multiplier);
  751. extern int rrddim_set_divisor(RRDSET *st, RRDDIM *rd, collected_number divisor);
  752. extern RRDDIM *rrddim_find(RRDSET *st, const char *id);
  753. extern int rrddim_hide(RRDSET *st, const char *id);
  754. extern int rrddim_unhide(RRDSET *st, const char *id);
  755. extern void rrddim_is_obsolete(RRDSET *st, RRDDIM *rd);
  756. extern void rrddim_isnot_obsolete(RRDSET *st, RRDDIM *rd);
  757. extern collected_number rrddim_set_by_pointer(RRDSET *st, RRDDIM *rd, collected_number value);
  758. extern collected_number rrddim_set(RRDSET *st, const char *id, collected_number value);
  759. extern long align_entries_to_pagesize(RRD_MEMORY_MODE mode, long entries);
  760. // ----------------------------------------------------------------------------
  761. // RRD internal functions
  762. #ifdef NETDATA_RRD_INTERNALS
  763. extern avl_tree_lock rrdhost_root_index;
  764. extern char *rrdset_strncpyz_name(char *to, const char *from, size_t length);
  765. extern char *rrdset_cache_dir(RRDHOST *host, const char *id, const char *config_section);
  766. extern void rrddim_free(RRDSET *st, RRDDIM *rd);
  767. extern int rrddim_compare(void* a, void* b);
  768. extern int rrdset_compare(void* a, void* b);
  769. extern int rrdset_compare_name(void* a, void* b);
  770. extern int rrdfamily_compare(void *a, void *b);
  771. extern RRDFAMILY *rrdfamily_create(RRDHOST *host, const char *id);
  772. extern void rrdfamily_free(RRDHOST *host, RRDFAMILY *rc);
  773. #define rrdset_index_add(host, st) (RRDSET *)avl_insert_lock(&((host)->rrdset_root_index), (avl *)(st))
  774. #define rrdset_index_del(host, st) (RRDSET *)avl_remove_lock(&((host)->rrdset_root_index), (avl *)(st))
  775. extern RRDSET *rrdset_index_del_name(RRDHOST *host, RRDSET *st);
  776. extern void rrdset_free(RRDSET *st);
  777. extern void rrdset_reset(RRDSET *st);
  778. extern void rrdset_save(RRDSET *st);
  779. extern void rrdset_delete(RRDSET *st);
  780. extern void rrdset_delete_obsolete_dimensions(RRDSET *st);
  781. extern void rrdhost_cleanup_obsolete_charts(RRDHOST *host);
  782. #endif /* NETDATA_RRD_INTERNALS */
  783. // ----------------------------------------------------------------------------
  784. // RRD DB engine declarations
  785. #ifdef ENABLE_DBENGINE
  786. #include "database/engine/rrdengineapi.h"
  787. #endif
  788. #endif /* NETDATA_RRD_H */