]> arthur.barton.de Git - netdata.git/blob - src/rrd.h
14ef0f721275eb666388b7b18784d664e0c85ec6
[netdata.git] / src / rrd.h
1 #ifndef NETDATA_RRD_H
2 #define NETDATA_RRD_H 1
3
4 #define UPDATE_EVERY 1
5 #define UPDATE_EVERY_MAX 3600
6
7 #define RRD_DEFAULT_HISTORY_ENTRIES 3600
8 #define RRD_HISTORY_ENTRIES_MAX (86400*10)
9
10 extern int default_rrd_update_every;
11 extern int default_rrd_history_entries;
12
13 #define RRD_ID_LENGTH_MAX 200
14
15 #define RRDSET_MAGIC        "NETDATA RRD SET FILE V019"
16 #define RRDDIMENSION_MAGIC  "NETDATA RRD DIMENSION FILE V019"
17
18 typedef long long total_number;
19 #define TOTAL_NUMBER_FORMAT "%lld"
20
21 // ----------------------------------------------------------------------------
22 // chart types
23
24 typedef enum rrdset_type {
25     RRDSET_TYPE_LINE    = 0,
26     RRDSET_TYPE_AREA    = 1,
27     RRDSET_TYPE_STACKED = 2
28 } RRDSET_TYPE;
29
30 #define RRDSET_TYPE_LINE_NAME "line"
31 #define RRDSET_TYPE_AREA_NAME "area"
32 #define RRDSET_TYPE_STACKED_NAME "stacked"
33
34 RRDSET_TYPE rrdset_type_id(const char *name);
35 const char *rrdset_type_name(RRDSET_TYPE chart_type);
36
37
38 // ----------------------------------------------------------------------------
39 // memory mode
40
41 typedef enum rrd_memory_mode {
42     RRD_MEMORY_MODE_NONE = 0,
43     RRD_MEMORY_MODE_RAM  = 1,
44     RRD_MEMORY_MODE_MAP  = 2,
45     RRD_MEMORY_MODE_SAVE = 3
46 } RRD_MEMORY_MODE;
47
48 #define RRD_MEMORY_MODE_NONE_NAME "none"
49 #define RRD_MEMORY_MODE_RAM_NAME "ram"
50 #define RRD_MEMORY_MODE_MAP_NAME "map"
51 #define RRD_MEMORY_MODE_SAVE_NAME "save"
52
53 extern RRD_MEMORY_MODE default_rrd_memory_mode;
54
55 extern const char *rrd_memory_mode_name(RRD_MEMORY_MODE id);
56 extern RRD_MEMORY_MODE rrd_memory_mode_id(const char *name);
57
58
59 // ----------------------------------------------------------------------------
60 // algorithms types
61
62 typedef enum rrd_algorithm {
63     RRD_ALGORITHM_ABSOLUTE              = 0,
64     RRD_ALGORITHM_INCREMENTAL           = 1,
65     RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL = 2,
66     RRD_ALGORITHM_PCENT_OVER_ROW_TOTAL  = 3
67 } RRD_ALGORITHM;
68
69 #define RRD_ALGORITHM_ABSOLUTE_NAME                "absolute"
70 #define RRD_ALGORITHM_INCREMENTAL_NAME             "incremental"
71 #define RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL_NAME   "percentage-of-incremental-row"
72 #define RRD_ALGORITHM_PCENT_OVER_ROW_TOTAL_NAME    "percentage-of-absolute-row"
73
74 extern RRD_ALGORITHM rrd_algorithm_id(const char *name);
75 extern const char *rrd_algorithm_name(RRD_ALGORITHM algorithm);
76
77 // ----------------------------------------------------------------------------
78 // flags
79
80 typedef enum rrddim_flags {
81     RRDDIM_FLAG_HIDDEN                          = 1 << 0,  // this dimension will not be offered to callers
82     RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS = 1 << 1,  // do not offer RESET or OVERFLOW info to callers
83     RRDDIM_FLAG_UPDATED                         = 1 << 2,  // the dimension has been updated since the last processing
84     RRDDIM_FLAG_EXPOSED                         = 1 << 3   // when set what have sent this dimension to the central netdata
85 } RRDDIM_FLAGS;
86
87 #define rrddim_flag_check(rd, flag) ((rd)->flags & flag)
88 #define rrddim_flag_set(rd, flag)   (rd)->flags |= flag
89 #define rrddim_flag_clear(rd, flag) (rd)->flags &= ~flag
90
91
92 // ----------------------------------------------------------------------------
93 // RRD FAMILY
94
95 struct rrdfamily {
96     avl avl;
97
98     const char *family;
99     uint32_t hash_family;
100
101     size_t use_count;
102
103     avl_tree_lock variables_root_index;
104 };
105 typedef struct rrdfamily RRDFAMILY;
106
107
108 // ----------------------------------------------------------------------------
109 // RRD DIMENSION - this is a metric
110
111 struct rrddim {
112     // ------------------------------------------------------------------------
113     // binary indexing structures
114
115     avl avl;                                        // the binary index - this has to be first member!
116
117     // ------------------------------------------------------------------------
118     // the dimension definition
119
120     const char *id;                                 // the id of this dimension (for internal identification)
121     const char *name;                               // the name of this dimension (as presented to user)
122                                                     // this is a pointer to the config structure
123                                                     // since the config always has a higher priority
124                                                     // (the user overwrites the name of the charts)
125                                                     // DO NOT FREE THIS - IT IS ALLOCATED IN CONFIG
126
127     RRD_ALGORITHM algorithm;                        // the algorithm that is applied to add new collected values
128     RRD_MEMORY_MODE rrd_memory_mode;                // the memory mode for this dimension
129
130     collected_number multiplier;                    // the multiplier of the collected values
131     collected_number divisor;                       // the divider of the collected values
132
133     uint32_t flags;                                 // options and status options for the dimension
134
135     // ------------------------------------------------------------------------
136     // members for temporary data we need for calculations
137
138     uint32_t hash;                                  // a simple hash of the id, to speed up searching / indexing
139                                                     // instead of strcmp() every item in the binary index
140                                                     // we first compare the hashes
141
142     uint32_t hash_name;                             // a simple hash of the name
143
144     char *cache_filename;                           // the filename we load/save from/to this set
145
146     size_t counter;                                 // the number of times we added values to this rrdim
147
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
152     calculated_number calculated_value;             // the current calculated value, after applying the algorithm - resets to zero after being used
153     calculated_number last_calculated_value;        // the last calculated value processed
154
155     calculated_number last_stored_value;            // the last value as stored in the database (after interpolation)
156
157     collected_number collected_value;               // the current value, as collected - resets to 0 after being used
158     collected_number last_collected_value;          // the last value that was collected, after being processed
159
160     // the *_volume members are used to calculate the accuracy of the rounding done by the
161     // storage number - they are printed to debug.log when debug is enabled for a set.
162     calculated_number collected_volume;             // the sum of all collected values so far
163     calculated_number stored_volume;                // the sum of all stored values so far
164
165     struct rrddim *next;                            // linking of dimensions within the same data set
166     struct rrdset *rrdset;
167
168     // ------------------------------------------------------------------------
169     // members for checking the data when loading from disk
170
171     long entries;                                   // how many entries this dimension has in ram
172                                                     // this is the same to the entries of the data set
173                                                     // we set it here, to check the data when we load it from disk.
174
175     int update_every;                               // every how many seconds is this updated
176
177     size_t memsize;                                 // the memory allocated for this dimension
178
179     char magic[sizeof(RRDDIMENSION_MAGIC) + 1];     // a string to be saved, used to identify our data file
180
181     struct rrddimvar *variables;
182
183     // ------------------------------------------------------------------------
184     // the values stored in this dimension, using our floating point numbers
185
186     storage_number values[];                        // the array of values - THIS HAS TO BE THE LAST MEMBER
187 };
188 typedef struct rrddim RRDDIM;
189
190 // ----------------------------------------------------------------------------
191 // these loop macros make sure the linked list is accessed with the right lock
192
193 #define rrddim_foreach_read(rd, st) \
194     for(rd = st->dimensions, rrdset_check_rdlock(st); rd ; rd = rd->next)
195
196 #define rrddim_foreach_write(rd, st) \
197     for(rd = st->dimensions, rrdset_check_wrlock(st); rd ; rd = rd->next)
198
199
200 // ----------------------------------------------------------------------------
201 // RRDSET - this is a chart
202
203 typedef enum rrdset_flags {
204     RRDSET_FLAG_ENABLED = 1 << 0, // enables or disables a chart
205     RRDSET_FLAG_DETAIL  = 1 << 1, // if set, the data set should be considered as a detail of another
206                                   // (the master data set should be the one that has the same family and is not detail)
207     RRDSET_FLAG_DEBUG   = 1 << 2  // enables or disables debugging for a chart
208 } RRDSET_FLAGS;
209
210 #define rrdset_flag_check(st, flag) ((st)->flags & flag)
211 #define rrdset_flag_set(st, flag)   (st)->flags |= flag
212 #define rrdset_flag_clear(st, flag) (st)->flags &= ~flag
213
214 struct rrdset {
215     // ------------------------------------------------------------------------
216     // binary indexing structures
217
218     avl avl;                                        // the index, with key the id - this has to be first!
219     avl avlname;                                    // the index, with key the name
220
221     // ------------------------------------------------------------------------
222     // the set configuration
223
224     char id[RRD_ID_LENGTH_MAX + 1];                 // id of the data set
225
226     const char *name;                               // the name of this dimension (as presented to user)
227                                                     // this is a pointer to the config structure
228                                                     // since the config always has a higher priority
229                                                     // (the user overwrites the name of the charts)
230
231     char *config_section;                           // the config section for the chart
232
233     char *type;                                     // the type of graph RRD_TYPE_* (a category, for determining graphing options)
234     char *family;                                   // grouping sets under the same family
235     char *title;                                    // title shown to user
236     char *units;                                    // units of measurement
237
238     char *context;                                  // the template of this data set
239     uint32_t hash_context;
240
241     RRDSET_TYPE chart_type;
242
243     int update_every;                               // every how many seconds is this updated?
244
245     long entries;                                   // total number of entries in the data set
246
247     long current_entry;                             // the entry that is currently being updated
248                                                     // it goes around in a round-robin fashion
249
250     uint32_t flags;
251
252     int gap_when_lost_iterations_above;             // after how many lost iterations a gap should be stored
253                                                     // netdata will interpolate values for gaps lower than this
254
255     long priority;
256
257
258     // ------------------------------------------------------------------------
259     // members for temporary data we need for calculations
260
261     RRD_MEMORY_MODE rrd_memory_mode;                // if set to 1, this is memory mapped
262
263     char *cache_dir;                                // the directory to store dimensions
264     char cache_filename[FILENAME_MAX+1];            // the filename to store this set
265
266     pthread_rwlock_t rrdset_rwlock;                 // protects dimensions linked list
267
268     unsigned long counter;                          // the number of times we added values to this rrd
269     unsigned long counter_done;                     // the number of times we added values to this rrd
270
271     uint32_t hash;                                  // a simple hash on the id, to speed up searching
272                                                     // we first compare hashes, and only if the hashes are equal we do string comparisons
273
274     uint32_t hash_name;                             // a simple hash on the name
275
276     usec_t usec_since_last_update;                  // the time in microseconds since the last collection of data
277
278     struct timeval last_updated;                    // when this data set was last updated (updated every time the rrd_stats_done() function)
279     struct timeval last_collected_time;             // when did this data set last collected values
280
281     total_number collected_total;                   // used internally to calculate percentages
282     total_number last_collected_total;              // used internally to calculate percentages
283
284     RRDFAMILY *rrdfamily;
285     struct rrdhost *rrdhost;
286
287     struct rrdset *next;                            // linking of rrdsets
288
289     // ------------------------------------------------------------------------
290     // local variables
291
292     calculated_number green;
293     calculated_number red;
294
295     avl_tree_lock variables_root_index;
296     RRDSETVAR *variables;
297     RRDCALC *alarms;
298
299     // ------------------------------------------------------------------------
300     // members for checking the data when loading from disk
301
302     unsigned long memsize;                          // how much mem we have allocated for this (without dimensions)
303
304     char magic[sizeof(RRDSET_MAGIC) + 1];           // our magic
305
306     // ------------------------------------------------------------------------
307     // the dimensions
308
309     avl_tree_lock dimensions_index;                 // the root of the dimensions index
310     RRDDIM *dimensions;                             // the actual data for every dimension
311
312 };
313 typedef struct rrdset RRDSET;
314
315 #define rrdset_rdlock(st) pthread_rwlock_rdlock(&((st)->rrdset_rwlock))
316 #define rrdset_wrlock(st) pthread_rwlock_wrlock(&((st)->rrdset_rwlock))
317 #define rrdset_unlock(st) pthread_rwlock_unlock(&((st)->rrdset_rwlock))
318
319 // ----------------------------------------------------------------------------
320 // these loop macros make sure the linked list is accessed with the right lock
321
322 #define rrdset_foreach_read(st, host) \
323     for(st = host->rrdset_root, rrdhost_check_rdlock(host); st ; st = st->next)
324
325 #define rrdset_foreach_write(st, host) \
326     for(st = host->rrdset_root, rrdhost_check_wrlock(host); st ; st = st->next)
327
328
329 // ----------------------------------------------------------------------------
330 // RRD HOST
331
332 struct rrdhost {
333     avl avl;                                        // the index of hosts
334
335     char *hostname;                                 // the hostname of this host
336     uint32_t hash_hostname;                         // the hostname hash
337
338     char machine_guid[GUID_LEN + 1];                // the unique ID of this host
339     uint32_t hash_machine_guid;                     // the hash of the unique ID
340
341     int rrd_update_every;                           // the update frequency of the host
342     int rrd_history_entries;                        // the number of history entries for the host's charts
343
344     int rrdpush_enabled;                            // 1 when this host sends metrics to another netdata
345     char *rrdpush_destination;                      // where to send metrics to
346     char *rrdpush_api_key;                          // the api key at the receiving netdata
347     volatile int rrdpush_connected;                 // 1 when the sender is ready to push metrics
348     volatile int rrdpush_spawn;                     // 1 when the sender thread has been spawn
349     volatile int rrdpush_error_shown;               // 1 when we have logged a communication error
350     int rrdpush_socket;                             // the fd of the socket to the remote host, or -1
351     pthread_t rrdpush_thread;                       // the sender thread
352     pthread_mutex_t rrdpush_mutex;                  // exclusive access to rrdpush_buffer
353     int rrdpush_pipe[2];                            // collector to sender thread communication
354     BUFFER *rrdpush_buffer;                         // collector fills it, sender sends them
355
356     int health_enabled;                             // 1 when this host has health enabled
357     time_t health_delay_up_to;                      // a timestamp to delay alarms processing up to
358     RRD_MEMORY_MODE rrd_memory_mode;                // the memory more for the charts of this host
359
360     RRDSET *rrdset_root;                            // the host charts
361
362     pthread_rwlock_t rrdhost_rwlock;                // lock for this RRDHOST (protects rrdset_root linked list)
363
364     avl_tree_lock rrdset_root_index;                // the host's charts index (by id)
365     avl_tree_lock rrdset_root_index_name;           // the host's charts index (by name)
366
367     avl_tree_lock rrdfamily_root_index;             // the host's chart families index
368     avl_tree_lock variables_root_index;             // the host's chart variables index
369
370     char *cache_dir;                                // the directory to save RRD cache files
371     char *varlib_dir;                               // the directory to save health log
372
373     // all RRDCALCs are primarily allocated and linked here
374     // RRDCALCs may be linked to charts at any point
375     // (charts may or may not exist when these are loaded)
376     RRDCALC *alarms;
377
378     ALARM_LOG health_log;                           // alarms historical events (event log)
379
380     // templates of alarms
381     // these are used to create alarms when charts
382     // are created or renamed, that match them
383     RRDCALCTEMPLATE *templates;
384
385     char *os;                                       // the O/S type of the host
386     volatile size_t use_counter;                    // when remote hosts are streaming to this
387                                                     // host, this is the counter of connected clients
388
389     // health / alarm settings
390     char *health_default_exec;
391     char *health_default_recipient;
392     char *health_log_filename;
393     size_t health_log_entries_written;
394     FILE *health_log_fp;
395
396     struct rrdhost *next;
397 };
398 typedef struct rrdhost RRDHOST;
399 extern RRDHOST *localhost;
400
401 #define rrdhost_rdlock(h) pthread_rwlock_rdlock(&((h)->rrdhost_rwlock))
402 #define rrdhost_wrlock(h) pthread_rwlock_wrlock(&((h)->rrdhost_rwlock))
403 #define rrdhost_unlock(h) pthread_rwlock_unlock(&((h)->rrdhost_rwlock))
404
405 // ----------------------------------------------------------------------------
406 // these loop macros make sure the linked list is accessed with the right lock
407
408 #define rrdhost_foreach_read(var) \
409     for(var = localhost, rrd_check_rdlock(); var ; var = var->next)
410
411 #define rrdhost_foreach_write(var) \
412     for(var = localhost, rrd_check_wrlock(); var ; var = var->next)
413
414
415 // ----------------------------------------------------------------------------
416 // global lock for all RRDHOSTs
417
418 extern pthread_rwlock_t rrd_rwlock;
419 #define rrd_rdlock() pthread_rwlock_rdlock(&rrd_rwlock)
420 #define rrd_wrlock() pthread_rwlock_wrlock(&rrd_rwlock)
421 #define rrd_unlock() pthread_rwlock_unlock(&rrd_rwlock)
422
423 // ----------------------------------------------------------------------------
424
425 extern void rrd_init(char *hostname);
426
427 extern RRDHOST *rrdhost_find(const char *guid, uint32_t hash);
428 extern RRDHOST *rrdhost_find_or_create(
429         const char *hostname
430         , const char *guid
431         , const char *os
432         , int update_every
433         , int history
434         , RRD_MEMORY_MODE mode
435         , int health_enabled
436         , int rrdpush_enabled
437         , char *rrdpush_destination
438         , char *rrdpush_api_key
439 );
440
441 #ifdef NETDATA_INTERNAL_CHECKS
442 extern void rrdhost_check_wrlock_int(RRDHOST *host, const char *file, const char *function, const unsigned long line);
443 extern void rrdhost_check_rdlock_int(RRDHOST *host, const char *file, const char *function, const unsigned long line);
444 extern void rrdset_check_rdlock_int(RRDSET *st, const char *file, const char *function, const unsigned long line);
445 extern void rrdset_check_wrlock_int(RRDSET *st, const char *file, const char *function, const unsigned long line);
446 extern void rrd_check_rdlock_int(const char *file, const char *function, const unsigned long line);
447 extern void rrd_check_wrlock_int(const char *file, const char *function, const unsigned long line);
448
449 #define rrdhost_check_rdlock(host) rrdhost_check_rdlock_int(host, __FILE__, __FUNCTION__, __LINE__)
450 #define rrdhost_check_wrlock(host) rrdhost_check_wrlock_int(host, __FILE__, __FUNCTION__, __LINE__)
451 #define rrdset_check_rdlock(st) rrdset_check_rdlock_int(st, __FILE__, __FUNCTION__, __LINE__)
452 #define rrdset_check_wrlock(st) rrdset_check_wrlock_int(st, __FILE__, __FUNCTION__, __LINE__)
453 #define rrd_check_rdlock() rrd_check_rdlock_int(__FILE__, __FUNCTION__, __LINE__)
454 #define rrd_check_wrlock() rrd_check_wrlock_int(__FILE__, __FUNCTION__, __LINE__)
455
456 #else
457 #define rrdhost_check_rdlock(host) (void)0
458 #define rrdhost_check_wrlock(host) (void)0
459 #define rrdset_check_rdlock(host) (void)0
460 #define rrdset_check_wrlock(host) (void)0
461 #define rrd_check_rdlock() (void)0
462 #define rrd_check_wrlock() (void)0
463 #endif
464
465 // ----------------------------------------------------------------------------
466 // RRDSET functions
467
468 extern void rrdset_set_name(RRDSET *st, const char *name);
469
470 extern RRDSET *rrdset_create(RRDHOST *host
471                              , const char *type
472                              , const char *id
473                              , const char *name
474                              , const char *family
475                              , const char *context
476                              , const char *title
477                              , const char *units
478                              , long priority
479                              , int update_every
480                              , RRDSET_TYPE chart_type);
481
482 #define rrdset_create_localhost(type, id, name, family, context, title, units, priority, update_every, chart_type) rrdset_create(localhost, type, id, name, family, context, title, units, priority, update_every, chart_type)
483
484 extern void rrdhost_free_all(void);
485 extern void rrdhost_save_all(void);
486
487 extern void rrdhost_free(RRDHOST *host);
488 extern void rrdhost_save(RRDHOST *host);
489
490 extern RRDSET *rrdset_find(RRDHOST *host, const char *id);
491 #define rrdset_find_localhost(id) rrdset_find(localhost, id)
492
493 extern RRDSET *rrdset_find_bytype(RRDHOST *host, const char *type, const char *id);
494 #define rrdset_find_bytype_localhost(type, id) rrdset_find_bytype(localhost, type, id)
495
496 extern RRDSET *rrdset_find_byname(RRDHOST *host, const char *name);
497 #define rrdset_find_byname_localhost(name)  rrdset_find_byname(localhost, name)
498
499 extern void rrdset_next_usec_unfiltered(RRDSET *st, usec_t microseconds);
500 extern void rrdset_next_usec(RRDSET *st, usec_t microseconds);
501 #define rrdset_next(st) rrdset_next_usec(st, 0ULL)
502
503 extern void rrdset_done(RRDSET *st);
504
505 // get the total duration in seconds of the round robin database
506 #define rrdset_duration(st) ((time_t)( (((st)->counter >= ((unsigned long)(st)->entries))?(unsigned long)(st)->entries:(st)->counter) * (st)->update_every ))
507
508 // get the timestamp of the last entry in the round robin database
509 #define rrdset_last_entry_t(st) ((time_t)(((st)->last_updated.tv_sec)))
510
511 // get the timestamp of first entry in the round robin database
512 #define rrdset_first_entry_t(st) ((time_t)(rrdset_last_entry_t(st) - rrdset_duration(st)))
513
514 // get the last slot updated in the round robin database
515 #define rrdset_last_slot(st) ((unsigned long)(((st)->current_entry == 0) ? (st)->entries - 1 : (st)->current_entry - 1))
516
517 // get the first / oldest slot updated in the round robin database
518 #define rrdset_first_slot(st) ((unsigned long)( (((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) ))
519
520 // get the slot of the round robin database, for the given timestamp (t)
521 // it always returns a valid slot, although may not be for the time requested if the time is outside the round robin database
522 #define rrdset_time2slot(st, t) ( \
523         (  (time_t)(t) >= rrdset_last_entry_t(st))  ? ( rrdset_last_slot(st) ) : \
524         ( ((time_t)(t) <= rrdset_first_entry_t(st)) ?   rrdset_first_slot(st) : \
525         ( (rrdset_last_slot(st) >= (unsigned long)((rrdset_last_entry_t(st) - (time_t)(t)) / (unsigned long)((st)->update_every)) ) ? \
526           (rrdset_last_slot(st) -  (unsigned long)((rrdset_last_entry_t(st) - (time_t)(t)) / (unsigned long)((st)->update_every)) ) : \
527           (rrdset_last_slot(st) -  (unsigned long)((rrdset_last_entry_t(st) - (time_t)(t)) / (unsigned long)((st)->update_every)) + (unsigned long)(st)->entries ) \
528         )))
529
530 // get the timestamp of a specific slot in the round robin database
531 #define rrdset_slot2time(st, slot) ( rrdset_last_entry_t(st) - \
532         ((unsigned long)(st)->update_every * ( \
533                 ( (unsigned long)(slot) > rrdset_last_slot(st)) ? \
534                 ( (rrdset_last_slot(st) - (unsigned long)(slot) + (unsigned long)(st)->entries) ) : \
535                 ( (rrdset_last_slot(st) - (unsigned long)(slot)) )) \
536         ))
537
538 // ----------------------------------------------------------------------------
539 // RRD DIMENSION functions
540
541 extern RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, collected_number multiplier, collected_number divisor, RRD_ALGORITHM algorithm);
542
543 extern void rrddim_set_name(RRDSET *st, RRDDIM *rd, const char *name);
544 extern RRDDIM *rrddim_find(RRDSET *st, const char *id);
545
546 extern int rrddim_hide(RRDSET *st, const char *id);
547 extern int rrddim_unhide(RRDSET *st, const char *id);
548
549 extern collected_number rrddim_set_by_pointer(RRDSET *st, RRDDIM *rd, collected_number value);
550 extern collected_number rrddim_set(RRDSET *st, const char *id, collected_number value);
551
552 extern long align_entries_to_pagesize(RRD_MEMORY_MODE mode, long entries);
553
554
555 // ----------------------------------------------------------------------------
556 // RRD internal functions
557
558 #ifdef NETDATA_RRD_INTERNALS
559
560 extern void rrdset_free(RRDSET *st);
561 extern avl_tree_lock rrdhost_root_index;
562
563 extern char *rrdset_strncpyz_name(char *to, const char *from, size_t length);
564 extern char *rrdset_cache_dir(RRDHOST *host, const char *id, const char *config_section);
565
566 extern void rrdset_reset(RRDSET *st);
567
568 extern void rrddim_free(RRDSET *st, RRDDIM *rd);
569
570 extern int rrddim_compare(void* a, void* b);
571 extern int rrdset_compare(void* a, void* b);
572 extern int rrdset_compare_name(void* a, void* b);
573 extern int rrdfamily_compare(void *a, void *b);
574
575 extern RRDFAMILY *rrdfamily_create(RRDHOST *host, const char *id);
576 extern void rrdfamily_free(RRDHOST *host, RRDFAMILY *rc);
577
578 #define rrdset_index_add(host, st) (RRDSET *)avl_insert_lock(&((host)->rrdset_root_index), (avl *)(st))
579 #define rrdset_index_del(host, st) (RRDSET *)avl_remove_lock(&((host)->rrdset_root_index), (avl *)(st))
580 extern RRDSET *rrdset_index_del_name(RRDHOST *host, RRDSET *st);
581
582 #endif /* NETDATA_RRD_INTERNALS */
583
584
585 #endif /* NETDATA_RRD_H */