#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <pthread.h>
#include <errno.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdlib.h>
#include "common.h"
#include "log.h"
#include "appconfig.h"
#include "rrd.h"
#define RRD_DEFAULT_GAP_INTERPOLATIONS 1
// ----------------------------------------------------------------------------
// globals
// if not zero it gives the time (in seconds) to remove un-updated dimensions
// DO NOT ENABLE
// if dimensions are removed, the chart generation will have to run again
int rrd_delete_unupdated_dimensions = 0;
int rrd_update_every = UPDATE_EVERY;
int rrd_default_history_entries = RRD_DEFAULT_HISTORY_ENTRIES;
RRDSET *rrdset_root = NULL;
pthread_rwlock_t rrdset_root_rwlock = PTHREAD_RWLOCK_INITIALIZER;
int rrd_memory_mode = RRD_MEMORY_MODE_SAVE;
// ----------------------------------------------------------------------------
// RRDSET index
static int rrdset_iterator(avl *a) { if(a) {}; return 0; }
static int rrdset_compare(void* a, void* b) {
if(((RRDSET *)a)->hash < ((RRDSET *)b)->hash) return -1;
else if(((RRDSET *)a)->hash > ((RRDSET *)b)->hash) return 1;
else return strcmp(((RRDSET *)a)->id, ((RRDSET *)b)->id);
}
avl_tree rrdset_root_index = {
NULL,
rrdset_compare,
#ifdef AVL_LOCK_WITH_MUTEX
PTHREAD_MUTEX_INITIALIZER
#else
PTHREAD_RWLOCK_INITIALIZER
#endif
};
#define rrdset_index_add(st) avl_insert(&rrdset_root_index, (avl *)(st))
#define rrdset_index_del(st) avl_remove(&rrdset_root_index, (avl *)(st))
static