}
}
-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;
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);
st->name = NULL;
st->type = NULL;
st->family = NULL;
+ st->context = NULL;
st->title = NULL;
st->units = NULL;
st->dimensions = NULL;
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;
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)
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)) {