diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-06 16:11:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-06 16:11:34 +0000 |
commit | d079b656b4719739b2247dcd9d46e9bec793095a (patch) | |
tree | d2c950c70a776bcf697c963151c5bd959f8a9f03 /health/health_config.c | |
parent | Releasing debian version 1.37.1-2. (diff) | |
download | netdata-d079b656b4719739b2247dcd9d46e9bec793095a.tar.xz netdata-d079b656b4719739b2247dcd9d46e9bec793095a.zip |
Merging upstream version 1.38.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | health/health_config.c | 105 |
1 files changed, 57 insertions, 48 deletions
diff --git a/health/health_config.c b/health/health_config.c index f9decfad5..55d5e10eb 100644 --- a/health/health_config.c +++ b/health/health_config.c @@ -553,33 +553,37 @@ static int health_readfile(const char *filename, void *data) { rt = NULL; } - rc = callocz(1, sizeof(RRDCALC)); - rc->next_event_id = 1; - - { - char *tmp = strdupz(value); - if(rrdvar_fix_name(tmp)) - error("Health configuration renamed alarm '%s' to '%s'", value, tmp); - - rc->name = string_strdupz(tmp); - freez(tmp); - } - - rc->source = health_source_file(line, filename); - rc->green = NAN; - rc->red = NAN; - rc->value = NAN; - rc->old_value = NAN; - rc->delay_multiplier = 1.0; - rc->old_status = RRDCALC_STATUS_UNINITIALIZED; - rc->warn_repeat_every = host->health_default_warn_repeat_every; - rc->crit_repeat_every = host->health_default_crit_repeat_every; - if (alert_cfg) - alert_config_free(alert_cfg); - alert_cfg = callocz(1, sizeof(struct alert_config)); - - alert_cfg->alarm = string_dup(rc->name); - ignore_this = 0; + if (simple_pattern_matches(conf_enabled_alarms, value)) { + rc = callocz(1, sizeof(RRDCALC)); + rc->next_event_id = 1; + + { + char *tmp = strdupz(value); + if(rrdvar_fix_name(tmp)) + error("Health configuration renamed alarm '%s' to '%s'", value, tmp); + + rc->name = string_strdupz(tmp); + freez(tmp); + } + + rc->source = health_source_file(line, filename); + rc->green = NAN; + rc->red = NAN; + rc->value = NAN; + rc->old_value = NAN; + rc->delay_multiplier = 1.0; + rc->old_status = RRDCALC_STATUS_UNINITIALIZED; + rc->warn_repeat_every = host->health.health_default_warn_repeat_every; + rc->crit_repeat_every = host->health.health_default_crit_repeat_every; + if (alert_cfg) + alert_config_free(alert_cfg); + alert_cfg = callocz(1, sizeof(struct alert_config)); + + alert_cfg->alarm = string_dup(rc->name); + ignore_this = 0; + } else { + rc = NULL; + } } else if(hash == hash_template && !strcasecmp(key, HEALTH_TEMPLATE_KEY)) { if(rc) { @@ -599,29 +603,33 @@ static int health_readfile(const char *filename, void *data) { rrdcalctemplate_add_from_config(host, rt); } - rt = callocz(1, sizeof(RRDCALCTEMPLATE)); + if (simple_pattern_matches(conf_enabled_alarms, value)) { + rt = callocz(1, sizeof(RRDCALCTEMPLATE)); - { - char *tmp = strdupz(value); - if(rrdvar_fix_name(tmp)) - error("Health configuration renamed template '%s' to '%s'", value, tmp); - - rt->name = string_strdupz(tmp); - freez(tmp); - } + { + char *tmp = strdupz(value); + if(rrdvar_fix_name(tmp)) + error("Health configuration renamed template '%s' to '%s'", value, tmp); - rt->source = health_source_file(line, filename); - rt->green = NAN; - rt->red = NAN; - rt->delay_multiplier = (float)1.0; - rt->warn_repeat_every = host->health_default_warn_repeat_every; - rt->crit_repeat_every = host->health_default_crit_repeat_every; - if (alert_cfg) - alert_config_free(alert_cfg); - alert_cfg = callocz(1, sizeof(struct alert_config)); + rt->name = string_strdupz(tmp); + freez(tmp); + } - alert_cfg->template_key = string_dup(rt->name); - ignore_this = 0; + rt->source = health_source_file(line, filename); + rt->green = NAN; + rt->red = NAN; + rt->delay_multiplier = (float)1.0; + rt->warn_repeat_every = host->health.health_default_warn_repeat_every; + rt->crit_repeat_every = host->health.health_default_crit_repeat_every; + if (alert_cfg) + alert_config_free(alert_cfg); + alert_cfg = callocz(1, sizeof(struct alert_config)); + + alert_cfg->template_key = string_dup(rt->name); + ignore_this = 0; + } else { + rt = NULL; + } } else if(hash == hash_os && !strcasecmp(key, HEALTH_OS_KEY)) { char *os_match = value; @@ -1163,7 +1171,8 @@ void sql_refresh_hashes(void) } void health_readdir(RRDHOST *host, const char *user_path, const char *stock_path, const char *subpath) { - if(unlikely(!host->health_enabled) && !rrdhost_flag_check(host, RRDHOST_FLAG_INITIALIZED_HEALTH)) { + if(unlikely((!host->health.health_enabled) && !rrdhost_flag_check(host, RRDHOST_FLAG_INITIALIZED_HEALTH)) || + !service_running(SERVICE_HEALTH)) { debug(D_HEALTH, "CONFIG health is not enabled for host '%s'", rrdhost_hostname(host)); return; } |