return 1;
}
- rv = rrdvar_index_find(&st->rrdcontext->variables_root_index, variable, hash);
+ rv = rrdvar_index_find(&st->rrdfamily->variables_root_index, variable, hash);
if(rv) {
*result = rrdvar2number(rv);
return 1;
debug(D_HEALTH, "Available local chart '%s' variables:", st->id);
avl_traverse_lock(&st->variables_root_index, dump_variable);
- debug(D_HEALTH, "Available context '%s' variables:", st->rrdcontext->id);
- avl_traverse_lock(&st->rrdcontext->variables_root_index, dump_variable);
+ debug(D_HEALTH, "Available context '%s' variables:", st->rrdfamily->family);
+ avl_traverse_lock(&st->rrdfamily->variables_root_index, dump_variable);
debug(D_HEALTH, "Available host '%s' variables:", st->rrdhost->hostname);
avl_traverse_lock(&st->rrdhost->variables_root_index, dump_variable);
rs->rrdset = st;
rs->local = rrdvar_create_and_index("local", &st->variables_root_index, rs->variable, rs->type, rs->value);
- rs->context = rrdvar_create_and_index("context", &st->rrdcontext->variables_root_index, rs->fullid, rs->type, rs->value);
+ rs->context = rrdvar_create_and_index("context", &st->rrdfamily->variables_root_index, rs->fullid, rs->type, rs->value);
rs->host = rrdvar_create_and_index("host", &st->rrdhost->variables_root_index, rs->fullid, rs->type, rs->value);
- rs->context_name = rrdvar_create_and_index("context", &st->rrdcontext->variables_root_index, rs->fullname, rs->type, rs->value);
+ rs->context_name = rrdvar_create_and_index("context", &st->rrdfamily->variables_root_index, rs->fullname, rs->type, rs->value);
rs->host_name = rrdvar_create_and_index("host", &st->rrdhost->variables_root_index, rs->fullname, rs->type, rs->value);
rs->next = st->variables;
if (strcmp(buffer, rs->fullname)) {
// name changed
- rrdvar_free(st->rrdhost, &st->rrdcontext->variables_root_index, rs->context_name);
+ rrdvar_free(st->rrdhost, &st->rrdfamily->variables_root_index, rs->context_name);
rrdvar_free(st->rrdhost, &st->rrdhost->variables_root_index, rs->host_name);
freez(rs->fullname);
rs->fullname = strdupz(st->name);
- rs->context_name = rrdvar_create_and_index("context", &st->rrdcontext->variables_root_index, rs->fullname, rs->type, rs->value);
+ rs->context_name = rrdvar_create_and_index("context", &st->rrdfamily->variables_root_index, rs->fullname, rs->type, rs->value);
rs->host_name = rrdvar_create_and_index("host", &st->rrdhost->variables_root_index, rs->fullname, rs->type, rs->value);
}
}
debug(D_VARIABLES, "RRDSETVAR free for chart id '%s' name '%s', variable '%s'", st->id, st->name, rs->variable);
rrdvar_free(st->rrdhost, &st->variables_root_index, rs->local);
- rrdvar_free(st->rrdhost, &st->rrdcontext->variables_root_index, rs->context);
+ rrdvar_free(st->rrdhost, &st->rrdfamily->variables_root_index, rs->context);
rrdvar_free(st->rrdhost, &st->rrdhost->variables_root_index, rs->host);
- rrdvar_free(st->rrdhost, &st->rrdcontext->variables_root_index, rs->context_name);
+ rrdvar_free(st->rrdhost, &st->rrdfamily->variables_root_index, rs->context_name);
rrdvar_free(st->rrdhost, &st->rrdhost->variables_root_index, rs->host_name);
if(st->variables == rs) {
rs->local_id = rrdvar_create_and_index("local", &st->variables_root_index, rs->id, rs->type, rs->value);
rs->local_name = rrdvar_create_and_index("local", &st->variables_root_index, rs->name, rs->type, rs->value);
- rs->context_id = rrdvar_create_and_index("context", &st->rrdcontext->variables_root_index, rs->id, rs->type, rs->value);
- rs->context_name = rrdvar_create_and_index("context", &st->rrdcontext->variables_root_index, rs->name, rs->type, rs->value);
+ rs->context_id = rrdvar_create_and_index("context", &st->rrdfamily->variables_root_index, rs->id, rs->type, rs->value);
+ rs->context_name = rrdvar_create_and_index("context", &st->rrdfamily->variables_root_index, rs->name, rs->type, rs->value);
rs->host_fullidid = rrdvar_create_and_index("host", &st->rrdhost->variables_root_index, rs->fullidid, rs->type, rs->value);
rs->host_fullidname = rrdvar_create_and_index("host", &st->rrdhost->variables_root_index, rs->fullidname, rs->type, rs->value);
rrdvar_free(st->rrdhost, &st->variables_root_index, rs->local_id);
rrdvar_free(st->rrdhost, &st->variables_root_index, rs->local_name);
- rrdvar_free(st->rrdhost, &st->rrdcontext->variables_root_index, rs->context_id);
- rrdvar_free(st->rrdhost, &st->rrdcontext->variables_root_index, rs->context_name);
+ rrdvar_free(st->rrdhost, &st->rrdfamily->variables_root_index, rs->context_id);
+ rrdvar_free(st->rrdhost, &st->rrdfamily->variables_root_index, rs->context_name);
rrdvar_free(st->rrdhost, &st->rrdhost->variables_root_index, rs->host_fullidid);
rrdvar_free(st->rrdhost, &st->rrdhost->variables_root_index, rs->host_fullidname);
st->red = rc->red;
rc->local = rrdvar_create_and_index("local", &st->variables_root_index, rc->name, RRDVAR_TYPE_CALCULATED, &rc->value);
- rc->context = rrdvar_create_and_index("context", &st->rrdcontext->variables_root_index, rc->name, RRDVAR_TYPE_CALCULATED, &rc->value);
+ rc->context = rrdvar_create_and_index("context", &st->rrdfamily->variables_root_index, rc->name, RRDVAR_TYPE_CALCULATED, &rc->value);
char fullname[RRDVAR_MAX_LENGTH + 1];
snprintfz(fullname, RRDVAR_MAX_LENGTH, "%s.%s", st->id, rc->name);
rrdvar_free(st->rrdhost, &st->variables_root_index, rc->local);
rc->local = NULL;
- rrdvar_free(st->rrdhost, &st->rrdcontext->variables_root_index, rc->context);
+ rrdvar_free(st->rrdhost, &st->rrdfamily->variables_root_index, rc->context);
rc->context = NULL;
rrdvar_free(st->rrdhost, &st->rrdhost->variables_root_index, rc->hostid);
const char *exec = ae->exec;
if(!exec) exec = health_default_exec;
- snprintfz(buffer, FILENAME_MAX, "exec %s '%s' '%s' '%s' '%s' '%0.0Lf' '%0.0Lf' '%s' '%u'",
+ snprintfz(buffer, FILENAME_MAX, "exec %s '%s' '%s' '%s' '%s' '%0.0Lf' '%0.0Lf' '%s' '%u' '%u'",
exec,
ae->name,
ae->chart?ae->chart:"NOCAHRT",
ae->new_value,
ae->old_value,
ae->source?ae->source:"UNKNOWN",
- (uint32_t)ae->duration
+ (uint32_t)ae->duration,
+ (uint32_t)ae->non_clear_duration
);
debug(D_HEALTH, "executing command '%s'", buffer);
ae->new_status = new_status;
ae->duration = duration;
+ if(ae->old_status == RRDCALC_STATUS_WARNING || ae->old_status == RRDCALC_STATUS_CRITICAL)
+ ae->non_clear_duration += ae->duration;
+
// link it
ae->next = health_log.alarms;
health_log.alarms = ae;
t->hash_chart == ae->hash_chart &&
!strcmp(t->name, ae->name) &&
t->chart && ae->chart && !strcmp(t->chart, ae->chart)) {
- t->notifications |= HEALTH_ENTRY_NOTIFICATIONS_UPDATED;
- t->updated_by = ae;
+
+ if(!(t->notifications & HEALTH_ENTRY_NOTIFICATIONS_UPDATED) && !t->updated_by) {
+ t->notifications |= HEALTH_ENTRY_NOTIFICATIONS_UPDATED;
+ t->updated_by = ae;
+
+ if((t->new_status == RRDCALC_STATUS_WARNING || t->new_status == RRDCALC_STATUS_CRITICAL) &&
+ (t->old_status == RRDCALC_STATUS_WARNING || t->old_status == RRDCALC_STATUS_CRITICAL))
+ ae->non_clear_duration += t->non_clear_duration;
+ }
+ else {
+ // no need to continue
+ break;
+ }
}
}
}
static int rrdset_compare(void* a, void* b);
static int rrdset_compare_name(void* a, void* b);
-static int rrdcontext_compare(void* a, void* b);
+static int rrdfamily_compare(void *a, void *b);
// ----------------------------------------------------------------------------
// RRDHOST
{ NULL, rrdset_compare_name },
AVL_LOCK_INITIALIZER
},
- .rrdcontext_root_index = {
- { NULL, rrdcontext_compare },
+ .rrdfamily_root_index = {
+ { NULL, rrdfamily_compare },
AVL_LOCK_INITIALIZER
},
.variables_root_index = {
}
// ----------------------------------------------------------------------------
-// RRDCONTEXT index
+// RRDFAMILY index
-static int rrdcontext_compare(void* a, void* b) {
- if(((RRDCONTEXT *)a)->hash < ((RRDCONTEXT *)b)->hash) return -1;
- else if(((RRDCONTEXT *)a)->hash > ((RRDCONTEXT *)b)->hash) return 1;
- else return strcmp(((RRDCONTEXT *)a)->id, ((RRDCONTEXT *)b)->id);
+static int rrdfamily_compare(void *a, void *b) {
+ if(((RRDFAMILY *)a)->hash_family < ((RRDFAMILY *)b)->hash_family) return -1;
+ else if(((RRDFAMILY *)a)->hash_family > ((RRDFAMILY *)b)->hash_family) return 1;
+ else return strcmp(((RRDFAMILY *)a)->family, ((RRDFAMILY *)b)->family);
}
-#define rrdcontext_index_add(host, rc) (RRDCONTEXT *)avl_insert_lock(&((host)->rrdcontext_root_index), (avl *)(rc))
-#define rrdcontext_index_del(host, rc) (RRDCONTEXT *)avl_remove_lock(&((host)->rrdcontext_root_index), (avl *)(rc))
+#define rrdfamily_index_add(host, rc) (RRDFAMILY *)avl_insert_lock(&((host)->rrdfamily_root_index), (avl *)(rc))
+#define rrdfamily_index_del(host, rc) (RRDFAMILY *)avl_remove_lock(&((host)->rrdfamily_root_index), (avl *)(rc))
-static RRDCONTEXT *rrdcontext_index_find(RRDHOST *host, const char *id, uint32_t hash) {
- RRDCONTEXT tmp;
- tmp.id = id;
- tmp.hash = (hash)?hash:simple_hash(tmp.id);
+static RRDFAMILY *rrdfamily_index_find(RRDHOST *host, const char *id, uint32_t hash) {
+ RRDFAMILY tmp;
+ tmp.family = id;
+ tmp.hash_family = (hash)?hash:simple_hash(tmp.family);
- return (RRDCONTEXT *)avl_search_lock(&(host->rrdcontext_root_index), (avl *) &tmp);
+ return (RRDFAMILY *)avl_search_lock(&(host->rrdfamily_root_index), (avl *) &tmp);
}
-RRDCONTEXT *rrdcontext_create(const char *id) {
- RRDCONTEXT *rc = rrdcontext_index_find(&localhost, id, 0);
+RRDFAMILY *rrdfamily_create(const char *id) {
+ RRDFAMILY *rc = rrdfamily_index_find(&localhost, id, 0);
if(!rc) {
- rc = callocz(1, sizeof(RRDCONTEXT));
+ rc = callocz(1, sizeof(RRDFAMILY));
- rc->id = strdupz(id);
- rc->hash = simple_hash(rc->id);
+ rc->family = strdupz(id);
+ rc->hash_family = simple_hash(rc->family);
// initialize the variables index
avl_init_lock(&rc->variables_root_index, rrdvar_compare);
- RRDCONTEXT *ret = rrdcontext_index_add(&localhost, rc);
+ RRDFAMILY *ret = rrdfamily_index_add(&localhost, rc);
if(ret != rc)
- fatal("INTERNAL ERROR: Expected to INSERT RRDCONTEXT '%s' into index, but inserted '%s'.", rc->id, (ret)?ret->id:"NONE");
+ fatal("INTERNAL ERROR: Expected to INSERT RRDFAMILY '%s' into index, but inserted '%s'.", rc->family, (ret)?ret->family:"NONE");
}
rc->use_count++;
return rc;
}
-void rrdcontext_free(RRDCONTEXT *rc) {
+void rrdfamily_free(RRDFAMILY *rc) {
rc->use_count--;
if(!rc->use_count) {
- RRDCONTEXT *ret = rrdcontext_index_del(&localhost, rc);
+ RRDFAMILY *ret = rrdfamily_index_del(&localhost, rc);
if(ret != rc)
- fatal("INTERNAL ERROR: Expected to DELETE RRDCONTEXT '%s' from index, but deleted '%s'.", rc->id, (ret)?ret->id:"NONE");
+ fatal("INTERNAL ERROR: Expected to DELETE RRDFAMILY '%s' from index, but deleted '%s'.", rc->family, (ret)?ret->family:"NONE");
if(rc->variables_root_index.avl_tree.root != NULL)
- fatal("INTERNAL ERROR: Variables index of RRDCONTEXT '%s' that is freed, is not empty.", rc->id);
+ fatal("INTERNAL ERROR: Variables index of RRDFAMILY '%s' that is freed, is not empty.", rc->family);
- freez((void *)rc->id);
+ freez((void *)rc->family);
freez(rc);
}
}
st->title = config_get(st->id, "title", varvalue);
}
- st->rrdcontext = rrdcontext_create(st->context);
+ st->rrdfamily = rrdfamily_create(st->family);
st->rrdhost = &localhost;
st->next = localhost.rrdset_root;
rrdset_index_del(&localhost, st);
- st->rrdcontext->use_count--;
- if(!st->rrdcontext->use_count)
- rrdcontext_free(st->rrdcontext);
+ st->rrdfamily->use_count--;
+ if(!st->rrdfamily->use_count)
+ rrdfamily_free(st->rrdfamily);
pthread_rwlock_unlock(&st->rwlock);