summaryrefslogtreecommitdiffstats
path: root/database/rrdcalc.c
diff options
context:
space:
mode:
authorEmmanuel Vasilakis <mrzammler@mm.st>2022-06-02 13:36:56 +0300
committerGitHub <noreply@github.com>2022-06-02 13:36:56 +0300
commit658f8f9073acecf57d330d4b3a875a70e66c3cc5 (patch)
tree85eb7fcfa75df2848372e47a87b5b801a63a00fc /database/rrdcalc.c
parent04b1c9e0dadbea871ca51342be8e71265c40034d (diff)
Check for host labels when linking alerts for children (#13053)
check for host labels when linking alerts
Diffstat (limited to 'database/rrdcalc.c')
-rw-r--r--database/rrdcalc.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/database/rrdcalc.c b/database/rrdcalc.c
index dc5673e907..b29a0ffc00 100644
--- a/database/rrdcalc.c
+++ b/database/rrdcalc.c
@@ -116,6 +116,31 @@ static inline int rrdcalc_test_additional_restriction(RRDCALC *rc, RRDSET *st){
if (rc->plugin_match && !simple_pattern_matches(rc->plugin_pattern, st->plugin_name))
return 0;
+ if (rc->labels) {
+ int labels_count=1;
+ int labels_match=0;
+ char *s = rc->labels;
+ while (*s) {
+ if (*s==' ')
+ labels_count++;
+ s++;
+ }
+ RRDHOST *host = st->rrdhost;
+ char cmp[CONFIG_FILE_LINE_MAX+1];
+ struct label *move = host->labels.head;
+ while(move) {
+ snprintf(cmp, CONFIG_FILE_LINE_MAX, "%s=%s", move->key, move->value);
+ if (simple_pattern_matches(rc->splabels, move->key) ||
+ simple_pattern_matches(rc->splabels, cmp)) {
+ labels_match++;
+ }
+ move = move->next;
+ }
+
+ if (labels_match != labels_count)
+ return 0;
+ }
+
return 1;
}