1 #define NETDATA_HEALTH_INTERNALS
4 // ----------------------------------------------------------------------------
5 // RRDCALCTEMPLATE management
7 void rrdcalctemplate_link_matching(RRDSET *st) {
10 for(rt = st->rrdhost->templates; rt ; rt = rt->next) {
11 if(rt->hash_context == st->hash_context && !strcmp(rt->context, st->context)
12 && (!rt->family_pattern || simple_pattern_matches(rt->family_pattern, st->family))) {
13 RRDCALC *rc = rrdcalc_create(st->rrdhost, rt, st->id);
15 error("Health tried to create alarm from template '%s', but it failed", rt->name);
17 #ifdef NETDATA_INTERNAL_CHECKS
18 else if(rc->rrdset != st)
19 error("Health alarm '%s.%s' should be linked to chart '%s', but it is not", rc->chart?rc->chart:"NOCHART", rc->name, st->id);
25 inline void rrdcalctemplate_free(RRDHOST *host, RRDCALCTEMPLATE *rt) {
26 if(unlikely(!rt)) return;
28 debug(D_HEALTH, "Health removing template '%s' of host '%s'", rt->name, host->hostname);
30 if(host->templates == rt) {
31 host->templates = rt->next;
35 for (t = host->templates; t && t->next != rt; t = t->next ) ;
41 error("Cannot find RRDCALCTEMPLATE '%s' linked in host '%s'", rt->name, host->hostname);
44 expression_free(rt->calculation);
45 expression_free(rt->warning);
46 expression_free(rt->critical);
48 freez(rt->family_match);
49 simple_pattern_free(rt->family_pattern);
58 freez(rt->dimensions);