summaryrefslogtreecommitdiffstats
path: root/health/health_config.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:30 +0000
commitaa2fe8ccbfcb117efa207d10229eeeac5d0f97c7 (patch)
tree941cbdd387b41c1a81587c20a6df9f0e5e0ff7ab /health/health_config.c
parentAdding upstream version 1.37.1. (diff)
downloadnetdata-aa2fe8ccbfcb117efa207d10229eeeac5d0f97c7.tar.xz
netdata-aa2fe8ccbfcb117efa207d10229eeeac5d0f97c7.zip
Adding upstream version 1.38.0.upstream/1.38.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'health/health_config.c')
-rw-r--r--health/health_config.c105
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;
}