summaryrefslogtreecommitdiffstats
path: root/health/health_config.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-12-01 06:15:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-12-01 06:15:04 +0000
commite970e0b37b8bd7f246feb3f70c4136418225e434 (patch)
tree0b67c0ca45f56f2f9d9c5c2e725279ecdf52d2eb /health/health_config.c
parentAdding upstream version 1.31.0. (diff)
downloadnetdata-e970e0b37b8bd7f246feb3f70c4136418225e434.tar.xz
netdata-e970e0b37b8bd7f246feb3f70c4136418225e434.zip
Adding upstream version 1.32.0.upstream/1.32.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'health/health_config.c')
-rw-r--r--health/health_config.c153
1 files changed, 146 insertions, 7 deletions
diff --git a/health/health_config.c b/health/health_config.c
index 756023715..35234df15 100644
--- a/health/health_config.c
+++ b/health/health_config.c
@@ -473,6 +473,29 @@ static inline char *health_source_file(size_t line, const char *file) {
return strdupz(buffer);
}
+char *health_edit_command_from_source(const char *source)
+{
+ char buffer[FILENAME_MAX + 1];
+ char *temp = strdupz(source);
+ char *line_num = strchr(temp, '@');
+ char *file_no_path = strrchr(temp, '/');
+
+ if (likely(file_no_path && line_num)) {
+ *line_num = '\0';
+ snprintfz(
+ buffer,
+ FILENAME_MAX,
+ "sudo %s/edit-config health.d/%s=%s",
+ netdata_configured_user_config_dir,
+ file_no_path + 1,
+ temp);
+ } else
+ buffer[0] = '\0';
+
+ freez(temp);
+ return strdupz(buffer);
+}
+
static inline void strip_quotes(char *s) {
while(*s) {
if(*s == '\'' || *s == '"') *s = ' ';
@@ -480,6 +503,40 @@ static inline void strip_quotes(char *s) {
}
}
+static inline void alert_config_free(struct alert_config *cfg)
+{
+ freez(cfg->alarm);
+ freez(cfg->template_key);
+ freez(cfg->os);
+ freez(cfg->host);
+ freez(cfg->on);
+ freez(cfg->families);
+ freez(cfg->plugin);
+ freez(cfg->module);
+ freez(cfg->charts);
+ freez(cfg->lookup);
+ freez(cfg->calc);
+ freez(cfg->warn);
+ freez(cfg->crit);
+ freez(cfg->every);
+ freez(cfg->green);
+ freez(cfg->red);
+ freez(cfg->exec);
+ freez(cfg->to);
+ freez(cfg->units);
+ freez(cfg->info);
+ freez(cfg->classification);
+ freez(cfg->component);
+ freez(cfg->type);
+ freez(cfg->delay);
+ freez(cfg->options);
+ freez(cfg->repeat);
+ freez(cfg->host_labels);
+ freez(cfg->p_db_lookup_dimensions);
+ freez(cfg->p_db_lookup_method);
+ freez(cfg);
+}
+
static int health_readfile(const char *filename, void *data) {
RRDHOST *host = (RRDHOST *)data;
@@ -554,6 +611,7 @@ static int health_readfile(const char *filename, void *data) {
RRDCALC *rc = NULL;
RRDCALCTEMPLATE *rt = NULL;
+ struct alert_config *alert_cfg = NULL;
int ignore_this = 0;
size_t line = 0, append = 0;
@@ -603,16 +661,18 @@ static int health_readfile(const char *filename, void *data) {
if(hash == hash_alarm && !strcasecmp(key, HEALTH_ALARM_KEY)) {
if(rc) {
- if(ignore_this || !rrdcalc_add_alarm_from_config(host, rc)) {
+ if(ignore_this || !alert_hash_and_store_config(rc->config_hash_id, alert_cfg) || !rrdcalc_add_alarm_from_config(host, rc)) {
rrdcalc_free(rc);
+ alert_config_free(alert_cfg);
}
// health_add_alarms_loop(host, rc, ignore_this) ;
}
if(rt) {
- if (ignore_this || !rrdcalctemplate_add_template_from_config(host, rt))
+ if (ignore_this || !alert_hash_and_store_config(rt->config_hash_id, alert_cfg) || !rrdcalctemplate_add_template_from_config(host, rt)) {
rrdcalctemplate_free(rt);
-
+ alert_config_free(alert_cfg);
+ }
rt = NULL;
}
@@ -629,25 +689,30 @@ static int health_readfile(const char *filename, void *data) {
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;
+ alert_cfg = callocz(1, sizeof(struct alert_config));
if(rrdvar_fix_name(rc->name))
error("Health configuration renamed alarm '%s' to '%s'", value, rc->name);
+ alert_cfg->alarm = strdupz(rc->name);
ignore_this = 0;
}
else if(hash == hash_template && !strcasecmp(key, HEALTH_TEMPLATE_KEY)) {
if(rc) {
// health_add_alarms_loop(host, rc, ignore_this) ;
- if(ignore_this || !rrdcalc_add_alarm_from_config(host, rc)) {
+ if(ignore_this || !alert_hash_and_store_config(rc->config_hash_id, alert_cfg) || !rrdcalc_add_alarm_from_config(host, rc)) {
rrdcalc_free(rc);
+ alert_config_free(alert_cfg);
}
rc = NULL;
}
if(rt) {
- if(ignore_this || !rrdcalctemplate_add_template_from_config(host, rt))
+ if(ignore_this || !alert_hash_and_store_config(rt->config_hash_id, alert_cfg) || !rrdcalctemplate_add_template_from_config(host, rt)) {
rrdcalctemplate_free(rt);
+ alert_config_free(alert_cfg);
+ }
}
rt = callocz(1, sizeof(RRDCALCTEMPLATE));
@@ -659,14 +724,17 @@ static int health_readfile(const char *filename, void *data) {
rt->delay_multiplier = 1.0;
rt->warn_repeat_every = host->health_default_warn_repeat_every;
rt->crit_repeat_every = host->health_default_crit_repeat_every;
+ alert_cfg = callocz(1, sizeof(struct alert_config));
if(rrdvar_fix_name(rt->name))
error("Health configuration renamed template '%s' to '%s'", value, rt->name);
+ alert_cfg->template_key = strdupz(rt->name);
ignore_this = 0;
}
else if(hash == hash_os && !strcasecmp(key, HEALTH_OS_KEY)) {
char *os_match = value;
+ if (alert_cfg) alert_cfg->os = strdupz(value);
SIMPLE_PATTERN *os_pattern = simple_pattern_create(os_match, NULL, SIMPLE_PATTERN_EXACT);
if(!simple_pattern_matches(os_pattern, host->os)) {
@@ -683,6 +751,7 @@ static int health_readfile(const char *filename, void *data) {
}
else if(hash == hash_host && !strcasecmp(key, HEALTH_HOST_KEY)) {
char *host_match = value;
+ if (alert_cfg) alert_cfg->host = strdupz(value);
SIMPLE_PATTERN *host_pattern = simple_pattern_create(host_match, NULL, SIMPLE_PATTERN_EXACT);
if(!simple_pattern_matches(host_pattern, host->hostname)) {
@@ -699,6 +768,7 @@ static int health_readfile(const char *filename, void *data) {
}
else if(rc) {
if(hash == hash_on && !strcasecmp(key, HEALTH_ON_KEY)) {
+ alert_cfg->on = strdupz(value);
if(rc->chart) {
if(strcmp(rc->chart, value) != 0)
error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -710,6 +780,7 @@ static int health_readfile(const char *filename, void *data) {
rc->hash_chart = simple_hash(rc->chart);
}
else if(hash == hash_class && !strcasecmp(key, HEALTH_CLASS_KEY)) {
+ alert_cfg->classification = strdupz(value);
if(rc->classification) {
if(strcmp(rc->classification, value) != 0)
error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -721,6 +792,7 @@ static int health_readfile(const char *filename, void *data) {
strip_quotes(rc->classification);
}
else if(hash == hash_component && !strcasecmp(key, HEALTH_COMPONENT_KEY)) {
+ alert_cfg->component = strdupz(value);
if(rc->component) {
if(strcmp(rc->component, value) != 0)
error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -732,6 +804,7 @@ static int health_readfile(const char *filename, void *data) {
strip_quotes(rc->component);
}
else if(hash == hash_type && !strcasecmp(key, HEALTH_TYPE_KEY)) {
+ alert_cfg->type = strdupz(value);
if(rc->type) {
if(strcmp(rc->type, value) != 0)
error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -743,18 +816,32 @@ static int health_readfile(const char *filename, void *data) {
strip_quotes(rc->type);
}
else if(hash == hash_lookup && !strcasecmp(key, HEALTH_LOOKUP_KEY)) {
+ alert_cfg->lookup = strdupz(value);
health_parse_db_lookup(line, filename, value, &rc->group, &rc->after, &rc->before,
&rc->update_every, &rc->options, &rc->dimensions, &rc->foreachdim);
if(rc->foreachdim) {
rc->spdim = health_pattern_from_foreach(rc->foreachdim);
}
+ if (rc->after) {
+ if (rc->dimensions)
+ alert_cfg->p_db_lookup_dimensions = strdupz(rc->dimensions);
+ if (rc->group)
+ alert_cfg->p_db_lookup_method = strdupz(group_method2string(rc->group));
+ alert_cfg->p_db_lookup_options = rc->options;
+ alert_cfg->p_db_lookup_after = rc->after;
+ alert_cfg->p_db_lookup_before = rc->before;
+ alert_cfg->p_update_every = rc->update_every;
+ }
}
else if(hash == hash_every && !strcasecmp(key, HEALTH_EVERY_KEY)) {
+ alert_cfg->every = strdupz(value);
if(!config_parse_duration(value, &rc->update_every))
error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' cannot parse duration: '%s'.",
line, filename, rc->name, key, value);
+ alert_cfg->p_update_every = rc->update_every;
}
else if(hash == hash_green && !strcasecmp(key, HEALTH_GREEN_KEY)) {
+ alert_cfg->green = strdupz(value);
char *e;
rc->green = str2ld(value, &e);
if(e && *e) {
@@ -763,6 +850,7 @@ static int health_readfile(const char *filename, void *data) {
}
}
else if(hash == hash_red && !strcasecmp(key, HEALTH_RED_KEY)) {
+ alert_cfg->red = strdupz(value);
char *e;
rc->red = str2ld(value, &e);
if(e && *e) {
@@ -771,6 +859,7 @@ static int health_readfile(const char *filename, void *data) {
}
}
else if(hash == hash_calc && !strcasecmp(key, HEALTH_CALC_KEY)) {
+ alert_cfg->calc = strdupz(value);
const char *failed_at = NULL;
int error = 0;
rc->calculation = expression_parse(value, &failed_at, &error);
@@ -780,6 +869,7 @@ static int health_readfile(const char *filename, void *data) {
}
}
else if(hash == hash_warn && !strcasecmp(key, HEALTH_WARN_KEY)) {
+ alert_cfg->warn = strdupz(value);
const char *failed_at = NULL;
int error = 0;
rc->warning = expression_parse(value, &failed_at, &error);
@@ -789,6 +879,7 @@ static int health_readfile(const char *filename, void *data) {
}
}
else if(hash == hash_crit && !strcasecmp(key, HEALTH_CRIT_KEY)) {
+ alert_cfg->crit = strdupz(value);
const char *failed_at = NULL;
int error = 0;
rc->critical = expression_parse(value, &failed_at, &error);
@@ -798,6 +889,7 @@ static int health_readfile(const char *filename, void *data) {
}
}
else if(hash == hash_exec && !strcasecmp(key, HEALTH_EXEC_KEY)) {
+ alert_cfg->exec = strdupz(value);
if(rc->exec) {
if(strcmp(rc->exec, value) != 0)
error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -808,6 +900,7 @@ static int health_readfile(const char *filename, void *data) {
rc->exec = strdupz(value);
}
else if(hash == hash_recipient && !strcasecmp(key, HEALTH_RECIPIENT_KEY)) {
+ alert_cfg->to = strdupz(value);
if(rc->recipient) {
if(strcmp(rc->recipient, value) != 0)
error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -818,6 +911,7 @@ static int health_readfile(const char *filename, void *data) {
rc->recipient = strdupz(value);
}
else if(hash == hash_units && !strcasecmp(key, HEALTH_UNITS_KEY)) {
+ alert_cfg->units = strdupz(value);
if(rc->units) {
if(strcmp(rc->units, value) != 0)
error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -829,6 +923,7 @@ static int health_readfile(const char *filename, void *data) {
strip_quotes(rc->units);
}
else if(hash == hash_info && !strcasecmp(key, HEALTH_INFO_KEY)) {
+ alert_cfg->info = strdupz(value);
if(rc->info) {
if(strcmp(rc->info, value) != 0)
error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -840,17 +935,21 @@ static int health_readfile(const char *filename, void *data) {
strip_quotes(rc->info);
}
else if(hash == hash_delay && !strcasecmp(key, HEALTH_DELAY_KEY)) {
+ alert_cfg->delay = strdupz(value);
health_parse_delay(line, filename, value, &rc->delay_up_duration, &rc->delay_down_duration, &rc->delay_max_duration, &rc->delay_multiplier);
}
else if(hash == hash_options && !strcasecmp(key, HEALTH_OPTIONS_KEY)) {
+ alert_cfg->options = strdupz(value);
rc->options |= health_parse_options(value);
}
else if(hash == hash_repeat && !strcasecmp(key, HEALTH_REPEAT_KEY)){
+ alert_cfg->repeat = strdupz(value);
health_parse_repeat(line, filename, value,
&rc->warn_repeat_every,
&rc->crit_repeat_every);
}
else if(hash == hash_host_label && !strcasecmp(key, HEALTH_HOST_LABEL_KEY)) {
+ alert_cfg->host_labels = strdupz(value);
if(rc->labels) {
if(strcmp(rc->labels, value) != 0)
error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'.",
@@ -864,6 +963,7 @@ static int health_readfile(const char *filename, void *data) {
rc->splabels = simple_pattern_create(rc->labels, NULL, SIMPLE_PATTERN_EXACT);
}
else if(hash == hash_plugin && !strcasecmp(key, HEALTH_PLUGIN_KEY)) {
+ alert_cfg->plugin = strdupz(value);
freez(rc->plugin_match);
simple_pattern_free(rc->plugin_pattern);
@@ -871,6 +971,7 @@ static int health_readfile(const char *filename, void *data) {
rc->plugin_pattern = simple_pattern_create(rc->plugin_match, NULL, SIMPLE_PATTERN_EXACT);
}
else if(hash == hash_module && !strcasecmp(key, HEALTH_MODULE_KEY)) {
+ alert_cfg->module = strdupz(value);
freez(rc->module_match);
simple_pattern_free(rc->module_pattern);
@@ -884,6 +985,7 @@ static int health_readfile(const char *filename, void *data) {
}
else if(rt) {
if(hash == hash_on && !strcasecmp(key, HEALTH_ON_KEY)) {
+ alert_cfg->on = strdupz(value);
if(rt->context) {
if(strcmp(rt->context, value) != 0)
error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -895,6 +997,7 @@ static int health_readfile(const char *filename, void *data) {
rt->hash_context = simple_hash(rt->context);
}
else if(hash == hash_class && !strcasecmp(key, HEALTH_CLASS_KEY)) {
+ alert_cfg->classification = strdupz(value);
if(rt->classification) {
if(strcmp(rt->classification, value) != 0)
error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -906,6 +1009,7 @@ static int health_readfile(const char *filename, void *data) {
strip_quotes(rt->classification);
}
else if(hash == hash_component && !strcasecmp(key, HEALTH_COMPONENT_KEY)) {
+ alert_cfg->component = strdupz(value);
if(rt->component) {
if(strcmp(rt->component, value) != 0)
error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -917,6 +1021,7 @@ static int health_readfile(const char *filename, void *data) {
strip_quotes(rt->component);
}
else if(hash == hash_type && !strcasecmp(key, HEALTH_TYPE_KEY)) {
+ alert_cfg->type = strdupz(value);
if(rt->type) {
if(strcmp(rt->type, value) != 0)
error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -928,6 +1033,7 @@ static int health_readfile(const char *filename, void *data) {
strip_quotes(rt->type);
}
else if(hash == hash_families && !strcasecmp(key, HEALTH_FAMILIES_KEY)) {
+ alert_cfg->families = strdupz(value);
freez(rt->family_match);
simple_pattern_free(rt->family_pattern);
@@ -935,6 +1041,7 @@ static int health_readfile(const char *filename, void *data) {
rt->family_pattern = simple_pattern_create(rt->family_match, NULL, SIMPLE_PATTERN_EXACT);
}
else if(hash == hash_plugin && !strcasecmp(key, HEALTH_PLUGIN_KEY)) {
+ alert_cfg->plugin = strdupz(value);
freez(rt->plugin_match);
simple_pattern_free(rt->plugin_pattern);
@@ -942,6 +1049,7 @@ static int health_readfile(const char *filename, void *data) {
rt->plugin_pattern = simple_pattern_create(rt->plugin_match, NULL, SIMPLE_PATTERN_EXACT);
}
else if(hash == hash_module && !strcasecmp(key, HEALTH_MODULE_KEY)) {
+ alert_cfg->module = strdupz(value);
freez(rt->module_match);
simple_pattern_free(rt->module_pattern);
@@ -949,6 +1057,7 @@ static int health_readfile(const char *filename, void *data) {
rt->module_pattern = simple_pattern_create(rt->module_match, NULL, SIMPLE_PATTERN_EXACT);
}
else if(hash == hash_charts && !strcasecmp(key, HEALTH_CHARTS_KEY)) {
+ alert_cfg->charts = strdupz(value);
freez(rt->charts_match);
simple_pattern_free(rt->charts_pattern);
@@ -956,18 +1065,32 @@ static int health_readfile(const char *filename, void *data) {
rt->charts_pattern = simple_pattern_create(rt->charts_match, NULL, SIMPLE_PATTERN_EXACT);
}
else if(hash == hash_lookup && !strcasecmp(key, HEALTH_LOOKUP_KEY)) {
+ alert_cfg->lookup = strdupz(value);
health_parse_db_lookup(line, filename, value, &rt->group, &rt->after, &rt->before,
&rt->update_every, &rt->options, &rt->dimensions, &rt->foreachdim);
if(rt->foreachdim) {
rt->spdim = health_pattern_from_foreach(rt->foreachdim);
}
+ if (rt->after) {
+ if (rt->dimensions)
+ alert_cfg->p_db_lookup_dimensions = strdupz(rt->dimensions);
+ if (rt->group)
+ alert_cfg->p_db_lookup_method = strdupz(group_method2string(rt->group));
+ alert_cfg->p_db_lookup_options = rt->options;
+ alert_cfg->p_db_lookup_after = rt->after;
+ alert_cfg->p_db_lookup_before = rt->before;
+ alert_cfg->p_update_every = rt->update_every;
+ }
}
else if(hash == hash_every && !strcasecmp(key, HEALTH_EVERY_KEY)) {
+ alert_cfg->every = strdupz(value);
if(!config_parse_duration(value, &rt->update_every))
error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' cannot parse duration: '%s'.",
line, filename, rt->name, key, value);
+ alert_cfg->p_update_every = rt->update_every;
}
else if(hash == hash_green && !strcasecmp(key, HEALTH_GREEN_KEY)) {
+ alert_cfg->green = strdupz(value);
char *e;
rt->green = str2ld(value, &e);
if(e && *e) {
@@ -976,6 +1099,7 @@ static int health_readfile(const char *filename, void *data) {
}
}
else if(hash == hash_red && !strcasecmp(key, HEALTH_RED_KEY)) {
+ alert_cfg->red = strdupz(value);
char *e;
rt->red = str2ld(value, &e);
if(e && *e) {
@@ -984,6 +1108,7 @@ static int health_readfile(const char *filename, void *data) {
}
}
else if(hash == hash_calc && !strcasecmp(key, HEALTH_CALC_KEY)) {
+ alert_cfg->calc = strdupz(value);
const char *failed_at = NULL;
int error = 0;
rt->calculation = expression_parse(value, &failed_at, &error);
@@ -993,6 +1118,7 @@ static int health_readfile(const char *filename, void *data) {
}
}
else if(hash == hash_warn && !strcasecmp(key, HEALTH_WARN_KEY)) {
+ alert_cfg->warn = strdupz(value);
const char *failed_at = NULL;
int error = 0;
rt->warning = expression_parse(value, &failed_at, &error);
@@ -1002,6 +1128,7 @@ static int health_readfile(const char *filename, void *data) {
}
}
else if(hash == hash_crit && !strcasecmp(key, HEALTH_CRIT_KEY)) {
+ alert_cfg->crit = strdupz(value);
const char *failed_at = NULL;
int error = 0;
rt->critical = expression_parse(value, &failed_at, &error);
@@ -1011,6 +1138,7 @@ static int health_readfile(const char *filename, void *data) {
}
}
else if(hash == hash_exec && !strcasecmp(key, HEALTH_EXEC_KEY)) {
+ alert_cfg->exec = strdupz(value);
if(rt->exec) {
if(strcmp(rt->exec, value) != 0)
error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -1021,6 +1149,7 @@ static int health_readfile(const char *filename, void *data) {
rt->exec = strdupz(value);
}
else if(hash == hash_recipient && !strcasecmp(key, HEALTH_RECIPIENT_KEY)) {
+ alert_cfg->to = strdupz(value);
if(rt->recipient) {
if(strcmp(rt->recipient, value) != 0)
error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -1031,6 +1160,7 @@ static int health_readfile(const char *filename, void *data) {
rt->recipient = strdupz(value);
}
else if(hash == hash_units && !strcasecmp(key, HEALTH_UNITS_KEY)) {
+ alert_cfg->units = strdupz(value);
if(rt->units) {
if(strcmp(rt->units, value) != 0)
error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -1042,6 +1172,7 @@ static int health_readfile(const char *filename, void *data) {
strip_quotes(rt->units);
}
else if(hash == hash_info && !strcasecmp(key, HEALTH_INFO_KEY)) {
+ alert_cfg->info = strdupz(value);
if(rt->info) {
if(strcmp(rt->info, value) != 0)
error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -1053,17 +1184,21 @@ static int health_readfile(const char *filename, void *data) {
strip_quotes(rt->info);
}
else if(hash == hash_delay && !strcasecmp(key, HEALTH_DELAY_KEY)) {
+ alert_cfg->delay = strdupz(value);
health_parse_delay(line, filename, value, &rt->delay_up_duration, &rt->delay_down_duration, &rt->delay_max_duration, &rt->delay_multiplier);
}
else if(hash == hash_options && !strcasecmp(key, HEALTH_OPTIONS_KEY)) {
+ alert_cfg->options = strdupz(value);
rt->options |= health_parse_options(value);
}
else if(hash == hash_repeat && !strcasecmp(key, HEALTH_REPEAT_KEY)){
+ alert_cfg->repeat = strdupz(value);
health_parse_repeat(line, filename, value,
&rt->warn_repeat_every,
&rt->crit_repeat_every);
}
else if(hash == hash_host_label && !strcasecmp(key, HEALTH_HOST_LABEL_KEY)) {
+ alert_cfg->host_labels = strdupz(value);
if(rt->labels) {
if(strcmp(rt->labels, value) != 0)
error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
@@ -1089,16 +1224,20 @@ static int health_readfile(const char *filename, void *data) {
if(rc) {
//health_add_alarms_loop(host, rc, ignore_this) ;
- if(ignore_this || !rrdcalc_add_alarm_from_config(host, rc)) {
+ if(ignore_this || !alert_hash_and_store_config(rc->config_hash_id, alert_cfg) || !rrdcalc_add_alarm_from_config(host, rc)) {
rrdcalc_free(rc);
}
}
if(rt) {
- if(ignore_this || !rrdcalctemplate_add_template_from_config(host, rt))
+ if(ignore_this || !alert_hash_and_store_config(rt->config_hash_id, alert_cfg) || !rrdcalctemplate_add_template_from_config(host, rt)) {
rrdcalctemplate_free(rt);
+ }
}
+ if (alert_cfg)
+ alert_config_free(alert_cfg);
+
fclose(fp);
return 1;
}