apply first alarms, then alarm templates (#17398)
apply first alarms, then templates
Costa Tsaousis committed
Apr 13, 2024 at 04:51 UTC
80d2dd74d0a3b03342d7768f1478a29c1ff78ca7
1 file changed
+18
-9
src/health/health_prototypes.c
+18
-9
@@ -575,18 +575,27 @@ static void health_prototype_apply_to_rrdset(RRDSET *st, RRD_ALERT_PROTOTYPE *ap
575
return;
576
577
spinlock_lock(&ap->_internal.spinlock);
578
- for(RRD_ALERT_PROTOTYPE *t = ap; t ; t = t->_internal.next) {
579
- if(!t->match.enabled)
580
- continue;
578
+ for(size_t template = 0; template < 2; template++) {
579
+ bool want_template = template ? true : false;
580
582
- if(!prototype_matches_host(st->rrdhost, t))
583
- continue;
581
+ for (RRD_ALERT_PROTOTYPE *t = ap; t; t = t->_internal.next) {
582
+ if (!t->match.enabled)
583
+ continue;
584
585
- if(!prototype_matches_rrdset(st, t))
586
- continue;
585
+ bool is_template = t->match.is_template ? true : false;
586
588
- if(rrdcalc_add_from_prototype(st->rrdhost, st, t))
589
- ap->_internal.uses++;
587
+ if (is_template != want_template)
588
+ continue;
589
+
590
+ if (!prototype_matches_host(st->rrdhost, t))
591
+ continue;
592
+
593
+ if (!prototype_matches_rrdset(st, t))
594
+ continue;
595
+
596
+ if (rrdcalc_add_from_prototype(st->rrdhost, st, t))
597
+ ap->_internal.uses++;
598
+ }
599
}
600
spinlock_unlock(&ap->_internal.spinlock);
601
}