]> arthur.barton.de Git - netdata.git/blobdiff - src/rrd.c
layout: remove executable from unrelated files
[netdata.git] / src / rrd.c
old mode 100755 (executable)
new mode 100644 (file)
index 5600375..2dce02e
--- a/src/rrd.c
+++ b/src/rrd.c
@@ -335,8 +335,13 @@ void rrdset_reset(RRDSET *st)
        }
 }
 
-RRDSET *rrdset_create(const char *type, const char *id, const char *name, const char *family, const char *title, const char *units, long priority, int update_every, int chart_type)
+RRDSET *rrdset_create(const char *type, const char *id, const char *name, const char *family, const char *context, const char *title, const char *units, long priority, int update_every, int chart_type)
 {
+       if(!type || !type[0]) {
+               fatal("Cannot create rrd stats without a type.");
+               return NULL;
+       }
+
        if(!id || !id[0]) {
                fatal("Cannot create rrd stats without an id.");
                return NULL;
@@ -348,6 +353,12 @@ RRDSET *rrdset_create(const char *type, const char *id, const char *name, const
 
        snprintf(fullid, RRD_ID_LENGTH_MAX, "%s.%s", type, id);
 
+       st = rrdset_find(fullid);
+       if(st) {
+               error("Cannot create rrd stats for '%s', it already exists.", fullid);
+               return st;
+       }
+
        long entries = config_get_number(fullid, "history", rrd_default_history_entries);
        if(entries < 5) entries = config_set_number(fullid, "history", 5);
        if(entries > RRD_HISTORY_ENTRIES_MAX) entries = config_set_number(fullid, "history", RRD_HISTORY_ENTRIES_MAX);
@@ -396,6 +407,7 @@ RRDSET *rrdset_create(const char *type, const char *id, const char *name, const
                st->name = NULL;
                st->type = NULL;
                st->family = NULL;
+               st->context = NULL;
                st->title = NULL;
                st->units = NULL;
                st->dimensions = NULL;
@@ -422,10 +434,11 @@ RRDSET *rrdset_create(const char *type, const char *id, const char *name, const
 
        st->cache_dir = cache_dir;
 
-       st->family     = config_get(st->id, "family", family?family:st->id);
-       st->units      = config_get(st->id, "units", units?units:"");
-       st->type       = config_get(st->id, "type", type);
        st->chart_type = rrdset_type_id(config_get(st->id, "chart type", rrdset_type_name(chart_type)));
+       st->type       = config_get(st->id, "type", type);
+       st->family     = config_get(st->id, "family", family?family:st->type);
+       st->context    = config_get(st->id, "context", context?context:st->id);
+       st->units      = config_get(st->id, "units", units?units:"");
 
        st->priority = config_get_number(st->id, "priority", priority);
        st->enabled = enabled;
@@ -592,7 +605,7 @@ void rrddim_set_name(RRDSET *st, RRDDIM *rd, const char *name)
 
        char varname[CONFIG_MAX_NAME + 1];
        snprintf(varname, CONFIG_MAX_NAME, "dim %s name", rd->id);
-       config_get(st->id, varname, name);
+       config_set_default(st->id, varname, name);
 }
 
 void rrddim_free(RRDSET *st, RRDDIM *rd)
@@ -1085,7 +1098,7 @@ unsigned long long rrdset_done(RRDSET *st)
 
        for( ; likely(next_ut <= now_ut) ; next_ut += st->update_every * 1000000ULL, iterations-- ) {
 #ifdef NETDATA_INTERNAL_CHECKS
-               if(iterations <= 0) { error("iterations calculation wrapped! first_ut = %llu, last_ut = %llu, next_ut = %llu, now_ut = %llu", first_ut, last_ut, next_ut, now_ut); }
+               if(iterations < 0) { error("%s: iterations calculation wrapped! first_ut = %llu, last_ut = %llu, next_ut = %llu, now_ut = %llu", st->name, first_ut, last_ut, next_ut, now_ut); }
 #endif
 
                if(unlikely(st->debug)) {