summaryrefslogtreecommitdiffstats
path: root/database/rrdcalc.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-05-08 16:27:08 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-05-08 16:27:08 +0000
commit81581f9719bc56f01d5aa08952671d65fda9867a (patch)
tree0f5c6b6138bf169c23c9d24b1fc0a3521385cb18 /database/rrdcalc.c
parentReleasing debian version 1.38.1-1. (diff)
downloadnetdata-81581f9719bc56f01d5aa08952671d65fda9867a.tar.xz
netdata-81581f9719bc56f01d5aa08952671d65fda9867a.zip
Merging upstream version 1.39.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'database/rrdcalc.c')
-rw-r--r--database/rrdcalc.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/database/rrdcalc.c b/database/rrdcalc.c
index 762635824..3ee8719c0 100644
--- a/database/rrdcalc.c
+++ b/database/rrdcalc.c
@@ -95,12 +95,12 @@ static STRING *rrdcalc_replace_variables_with_rrdset_labels(const char *line, RR
temp = buf;
}
else if (!strncmp(var, RRDCALC_VAR_LABEL, RRDCALC_VAR_LABEL_LEN)) {
- char label_val[RRDCALC_VAR_MAX + 1] = { 0 };
+ char label_val[RRDCALC_VAR_MAX + RRDCALC_VAR_LABEL_LEN + 1] = { 0 };
strcpy(label_val, var+RRDCALC_VAR_LABEL_LEN);
label_val[i - RRDCALC_VAR_LABEL_LEN - 1] = '\0';
if(likely(rc->rrdset && rc->rrdset->rrdlabels)) {
- rrdlabels_get_value_to_char_or_null(rc->rrdset->rrdlabels, &lbl_value, label_val);
+ rrdlabels_get_value_strdup_or_null(rc->rrdset->rrdlabels, &lbl_value, label_val);
if (lbl_value) {
char *buf = find_and_replace(temp, var, lbl_value, m);
freez(temp);
@@ -245,6 +245,8 @@ static void rrdcalc_link_to_rrdset(RRDSET *st, RRDCALC *rc) {
if(!rc->units)
rc->units = string_dup(st->units);
+ rrdvar_store_for_chart(host, st);
+
rrdcalc_update_info_using_rrdset_labels(rc);
time_t now = now_realtime_sec();
@@ -357,13 +359,14 @@ static inline bool rrdcalc_check_if_it_matches_rrdset(RRDCALC *rc, RRDSET *st) {
&& (rc->chart != st->name))
return false;
- if (rc->module_pattern && !simple_pattern_matches(rc->module_pattern, rrdset_module_name(st)))
+ if (rc->module_pattern && !simple_pattern_matches_string(rc->module_pattern, st->module_name))
return false;
- if (rc->plugin_pattern && !simple_pattern_matches(rc->plugin_pattern, rrdset_plugin_name(st)))
+ if (rc->plugin_pattern && !simple_pattern_matches_string(rc->plugin_pattern, st->module_name))
return false;
- if (st->rrdhost->rrdlabels && rc->host_labels_pattern && !rrdlabels_match_simple_pattern_parsed(st->rrdhost->rrdlabels, rc->host_labels_pattern, '='))
+ if (st->rrdhost->rrdlabels && rc->host_labels_pattern && !rrdlabels_match_simple_pattern_parsed(
+ st->rrdhost->rrdlabels, rc->host_labels_pattern, '=', NULL))
return false;
return true;
@@ -739,7 +742,7 @@ void rrdcalc_delete_alerts_not_matching_host_labels_from_this_host(RRDHOST *host
if (!rc->host_labels)
continue;
- if(!rrdlabels_match_simple_pattern_parsed(host->rrdlabels, rc->host_labels_pattern, '=')) {
+ if(!rrdlabels_match_simple_pattern_parsed(host->rrdlabels, rc->host_labels_pattern, '=', NULL)) {
log_health("Health configuration for alarm '%s' cannot be applied, because the host %s does not have the label(s) '%s'",
rrdcalc_name(rc),
rrdhost_hostname(host),
@@ -752,18 +755,15 @@ void rrdcalc_delete_alerts_not_matching_host_labels_from_this_host(RRDHOST *host
}
void rrdcalc_delete_alerts_not_matching_host_labels_from_all_hosts() {
- rrd_rdlock();
-
RRDHOST *host;
- rrdhost_foreach_read(host) {
+ dfe_start_reentrant(rrdhost_root_index, host) {
if (unlikely(!host->health.health_enabled))
continue;
if (host->rrdlabels)
rrdcalc_delete_alerts_not_matching_host_labels_from_this_host(host);
}
-
- rrd_unlock();
+ dfe_done(host);
}
void rrdcalc_unlink_all_rrdset_alerts(RRDSET *st) {