summaryrefslogtreecommitdiffstats
path: root/health/health_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'health/health_config.c')
-rw-r--r--health/health_config.c231
1 files changed, 119 insertions, 112 deletions
diff --git a/health/health_config.c b/health/health_config.c
index a11fd51cd..4e93235e2 100644
--- a/health/health_config.c
+++ b/health/health_config.c
@@ -61,36 +61,36 @@ static inline int health_parse_delay(
if(!strcasecmp(key, "up")) {
if (!config_parse_duration(value, delay_up_duration)) {
- error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
- line, filename, value, key);
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
+ line, filename, value, key);
}
else given_up = 1;
}
else if(!strcasecmp(key, "down")) {
if (!config_parse_duration(value, delay_down_duration)) {
- error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
- line, filename, value, key);
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
+ line, filename, value, key);
}
else given_down = 1;
}
else if(!strcasecmp(key, "multiplier")) {
*delay_multiplier = strtof(value, NULL);
if(isnan(*delay_multiplier) || isinf(*delay_multiplier) || islessequal(*delay_multiplier, 0)) {
- error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
- line, filename, value, key);
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
+ line, filename, value, key);
}
else given_multiplier = 1;
}
else if(!strcasecmp(key, "max")) {
if (!config_parse_duration(value, delay_max_duration)) {
- error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
- line, filename, value, key);
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
+ line, filename, value, key);
}
else given_max = 1;
}
else {
- error("Health configuration at line %zu of file '%s': unknown keyword '%s'",
- line, filename, key);
+ netdata_log_error("Health configuration at line %zu of file '%s': unknown keyword '%s'",
+ line, filename, key);
}
}
@@ -136,7 +136,7 @@ static inline uint32_t health_parse_options(const char *s) {
if(!strcasecmp(buf, "no-clear-notification") || !strcasecmp(buf, "no-clear"))
options |= RRDCALC_OPTION_NO_CLEAR_NOTIFICATION;
else
- error("Ignoring unknown alarm option '%s'", buf);
+ netdata_log_error("Ignoring unknown alarm option '%s'", buf);
}
}
@@ -171,14 +171,14 @@ static inline int health_parse_repeat(
}
if(!strcasecmp(key, "warning")) {
if (!config_parse_duration(value, (int*)warn_repeat_every)) {
- error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
- line, file, value, key);
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
+ line, file, value, key);
}
}
else if(!strcasecmp(key, "critical")) {
if (!config_parse_duration(value, (int*)crit_repeat_every)) {
- error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
- line, file, value, key);
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
+ line, file, value, key);
}
}
}
@@ -308,7 +308,7 @@ static inline int health_parse_db_lookup(
RRDR_TIME_GROUPING *group_method, int *after, int *before, int *every,
RRDCALC_OPTIONS *options, STRING **dimensions, STRING **foreachdim
) {
- debug(D_HEALTH, "Health configuration parsing database lookup %zu@%s: %s", line, filename, string);
+ netdata_log_debug(D_HEALTH, "Health configuration parsing database lookup %zu@%s: %s", line, filename, string);
if(*dimensions) string_freez(*dimensions);
if(*foreachdim) string_freez(*foreachdim);
@@ -326,14 +326,14 @@ static inline int health_parse_db_lookup(
while(*s && !isspace(*s)) s++;
while(*s && isspace(*s)) *s++ = '\0';
if(!*s) {
- error("Health configuration invalid chart calculation at line %zu of file '%s': expected group method followed by the 'after' time, but got '%s'",
- line, filename, key);
+ netdata_log_error("Health configuration invalid chart calculation at line %zu of file '%s': expected group method followed by the 'after' time, but got '%s'",
+ line, filename, key);
return 0;
}
if((*group_method = time_grouping_parse(key, RRDR_GROUPING_UNDEFINED)) == RRDR_GROUPING_UNDEFINED) {
- error("Health configuration at line %zu of file '%s': invalid group method '%s'",
- line, filename, key);
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid group method '%s'",
+ line, filename, key);
return 0;
}
@@ -343,8 +343,8 @@ static inline int health_parse_db_lookup(
while(*s && isspace(*s)) *s++ = '\0';
if(!config_parse_duration(key, after)) {
- error("Health configuration at line %zu of file '%s': invalid duration '%s' after group method",
- line, filename, key);
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid duration '%s' after group method",
+ line, filename, key);
return 0;
}
@@ -364,8 +364,8 @@ static inline int health_parse_db_lookup(
while(*s && isspace(*s)) *s++ = '\0';
if (!config_parse_duration(value, before)) {
- error("Health configuration at line %zu of file '%s': invalid duration '%s' for '%s' keyword",
- line, filename, value, key);
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid duration '%s' for '%s' keyword",
+ line, filename, value, key);
}
}
else if(!strcasecmp(key, HEALTH_EVERY_KEY)) {
@@ -374,8 +374,8 @@ static inline int health_parse_db_lookup(
while(*s && isspace(*s)) *s++ = '\0';
if (!config_parse_duration(value, every)) {
- error("Health configuration at line %zu of file '%s': invalid duration '%s' for '%s' keyword",
- line, filename, value, key);
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid duration '%s' for '%s' keyword",
+ line, filename, value, key);
}
}
else if(!strcasecmp(key, "absolute") || !strcasecmp(key, "abs") || !strcasecmp(key, "absolute_sum")) {
@@ -422,8 +422,8 @@ static inline int health_parse_db_lookup(
break;
}
else {
- error("Health configuration at line %zu of file '%s': unknown keyword '%s'",
- line, filename, key);
+ netdata_log_error("Health configuration at line %zu of file '%s': unknown keyword '%s'",
+ line, filename, key);
}
}
@@ -499,6 +499,7 @@ static inline void alert_config_free(struct alert_config *cfg)
string_freez(cfg->p_db_lookup_dimensions);
string_freez(cfg->p_db_lookup_method);
string_freez(cfg->chart_labels);
+ string_freez(cfg->source);
freez(cfg);
}
@@ -506,7 +507,7 @@ int sql_store_hashes = 1;
static int health_readfile(const char *filename, void *data) {
RRDHOST *host = (RRDHOST *)data;
- debug(D_HEALTH, "Health configuration reading file '%s'", filename);
+ netdata_log_debug(D_HEALTH, "Health configuration reading file '%s'", filename);
static uint32_t
hash_alarm = 0,
@@ -573,7 +574,7 @@ static int health_readfile(const char *filename, void *data) {
FILE *fp = fopen(filename, "r");
if(!fp) {
- error("Health configuration cannot read file '%s'.", filename);
+ netdata_log_error("Health configuration cannot read file '%s'.", filename);
return 0;
}
@@ -597,7 +598,8 @@ static int health_readfile(const char *filename, void *data) {
if(append < HEALTH_CONF_MAX_LINE)
continue;
else {
- error("Health configuration has too long multi-line at line %zu of file '%s'.", line, filename);
+ netdata_log_error("Health configuration has too long multi-line at line %zu of file '%s'.",
+ line, filename);
}
}
append = 0;
@@ -605,7 +607,8 @@ static int health_readfile(const char *filename, void *data) {
char *key = s;
while(*s && *s != ':') s++;
if(!*s) {
- error("Health configuration has invalid line %zu of file '%s'. It does not contain a ':'. Ignoring it.", line, filename);
+ netdata_log_error("Health configuration has invalid line %zu of file '%s'. It does not contain a ':'. Ignoring it.",
+ line, filename);
continue;
}
*s = '\0';
@@ -616,12 +619,14 @@ static int health_readfile(const char *filename, void *data) {
value = trim_all(value);
if(!key) {
- error("Health configuration has invalid line %zu of file '%s'. Keyword is empty. Ignoring it.", line, filename);
+ netdata_log_error("Health configuration has invalid line %zu of file '%s'. Keyword is empty. Ignoring it.",
+ line, filename);
continue;
}
if(!value) {
- error("Health configuration has invalid line %zu of file '%s'. value is empty. Ignoring it.", line, filename);
+ netdata_log_error("Health configuration has invalid line %zu of file '%s'. value is empty. Ignoring it.",
+ line, filename);
continue;
}
@@ -653,7 +658,7 @@ static int health_readfile(const char *filename, void *data) {
{
char *tmp = strdupz(value);
if(rrdvar_fix_name(tmp))
- error("Health configuration renamed alarm '%s' to '%s'", value, tmp);
+ netdata_log_error("Health configuration renamed alarm '%s' to '%s'", value, tmp);
rc->name = string_strdupz(tmp);
freez(tmp);
@@ -673,6 +678,7 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg = callocz(1, sizeof(struct alert_config));
alert_cfg->alarm = string_dup(rc->name);
+ alert_cfg->source = health_source_file(line, filename);
ignore_this = 0;
} else {
rc = NULL;
@@ -702,7 +708,7 @@ static int health_readfile(const char *filename, void *data) {
{
char *tmp = strdupz(value);
if(rrdvar_fix_name(tmp))
- error("Health configuration renamed template '%s' to '%s'", value, tmp);
+ netdata_log_error("Health configuration renamed template '%s' to '%s'", value, tmp);
rt->name = string_strdupz(tmp);
freez(tmp);
@@ -719,6 +725,7 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg = callocz(1, sizeof(struct alert_config));
alert_cfg->template_key = string_dup(rt->name);
+ alert_cfg->source = health_source_file(line, filename);
ignore_this = 0;
} else {
rt = NULL;
@@ -731,10 +738,10 @@ static int health_readfile(const char *filename, void *data) {
if(!simple_pattern_matches_string(os_pattern, host->os)) {
if(rc)
- debug(D_HEALTH, "HEALTH on '%s' ignoring alarm '%s' defined at %zu@%s: host O/S does not match '%s'", rrdhost_hostname(host), rrdcalc_name(rc), line, filename, os_match);
+ netdata_log_debug(D_HEALTH, "HEALTH on '%s' ignoring alarm '%s' defined at %zu@%s: host O/S does not match '%s'", rrdhost_hostname(host), rrdcalc_name(rc), line, filename, os_match);
if(rt)
- debug(D_HEALTH, "HEALTH on '%s' ignoring template '%s' defined at %zu@%s: host O/S does not match '%s'", rrdhost_hostname(host), rrdcalctemplate_name(rt), line, filename, os_match);
+ netdata_log_debug(D_HEALTH, "HEALTH on '%s' ignoring template '%s' defined at %zu@%s: host O/S does not match '%s'", rrdhost_hostname(host), rrdcalctemplate_name(rt), line, filename, os_match);
ignore_this = 1;
}
@@ -748,10 +755,10 @@ static int health_readfile(const char *filename, void *data) {
if(!simple_pattern_matches_string(host_pattern, host->hostname)) {
if(rc)
- debug(D_HEALTH, "HEALTH on '%s' ignoring alarm '%s' defined at %zu@%s: hostname does not match '%s'", rrdhost_hostname(host), rrdcalc_name(rc), line, filename, host_match);
+ netdata_log_debug(D_HEALTH, "HEALTH on '%s' ignoring alarm '%s' defined at %zu@%s: hostname does not match '%s'", rrdhost_hostname(host), rrdcalc_name(rc), line, filename, host_match);
if(rt)
- debug(D_HEALTH, "HEALTH on '%s' ignoring template '%s' defined at %zu@%s: hostname does not match '%s'", rrdhost_hostname(host), rrdcalctemplate_name(rt), line, filename, host_match);
+ netdata_log_debug(D_HEALTH, "HEALTH on '%s' ignoring template '%s' defined at %zu@%s: hostname does not match '%s'", rrdhost_hostname(host), rrdcalctemplate_name(rt), line, filename, host_match);
ignore_this = 1;
}
@@ -763,8 +770,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->on = string_strdupz(value);
if(rc->chart) {
if(strcmp(rrdcalc_chart_name(rc), 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').",
- line, filename, rrdcalc_name(rc), key, rrdcalc_chart_name(rc), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalc_name(rc), key, rrdcalc_chart_name(rc), value, value);
string_freez(rc->chart);
}
@@ -776,8 +783,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->classification = string_strdupz(value);
if(rc->classification) {
if(strcmp(rrdcalc_classification(rc), 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').",
- line, filename, rrdcalc_name(rc), key, rrdcalc_classification(rc), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalc_name(rc), key, rrdcalc_classification(rc), value, value);
string_freez(rc->classification);
}
@@ -789,7 +796,7 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->component = string_strdupz(value);
if(rc->component) {
if(strcmp(rrdcalc_component(rc), 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').",
+ netdata_log_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').",
line, filename, rrdcalc_name(rc), key, rrdcalc_component(rc), value, value);
string_freez(rc->component);
@@ -802,8 +809,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->type = string_strdupz(value);
if(rc->type) {
if(strcmp(rrdcalc_type(rc), 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').",
- line, filename, rrdcalc_name(rc), key, rrdcalc_type(rc), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalc_name(rc), key, rrdcalc_type(rc), value, value);
string_freez(rc->type);
}
@@ -831,8 +838,8 @@ static int health_readfile(const char *filename, void *data) {
else if(hash == hash_every && !strcasecmp(key, HEALTH_EVERY_KEY)) {
alert_cfg->every = string_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, rrdcalc_name(rc), key, value);
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' cannot parse duration: '%s'.",
+ line, filename, rrdcalc_name(rc), key, value);
alert_cfg->p_update_every = rc->update_every;
}
else if(hash == hash_green && !strcasecmp(key, HEALTH_GREEN_KEY)) {
@@ -840,8 +847,8 @@ static int health_readfile(const char *filename, void *data) {
char *e;
rc->green = str2ndd(value, &e);
if(e && *e) {
- error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' leaves this string unmatched: '%s'.",
- line, filename, rrdcalc_name(rc), key, e);
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' leaves this string unmatched: '%s'.",
+ line, filename, rrdcalc_name(rc), key, e);
}
}
else if(hash == hash_red && !strcasecmp(key, HEALTH_RED_KEY)) {
@@ -849,8 +856,8 @@ static int health_readfile(const char *filename, void *data) {
char *e;
rc->red = str2ndd(value, &e);
if(e && *e) {
- error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' leaves this string unmatched: '%s'.",
- line, filename, rrdcalc_name(rc), key, e);
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' leaves this string unmatched: '%s'.",
+ line, filename, rrdcalc_name(rc), key, e);
}
}
else if(hash == hash_calc && !strcasecmp(key, HEALTH_CALC_KEY)) {
@@ -859,8 +866,8 @@ static int health_readfile(const char *filename, void *data) {
int error = 0;
rc->calculation = expression_parse(value, &failed_at, &error);
if(!rc->calculation) {
- error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
- line, filename, rrdcalc_name(rc), key, value, expression_strerror(error), failed_at);
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
+ line, filename, rrdcalc_name(rc), key, value, expression_strerror(error), failed_at);
}
parse_variables_and_store_in_health_rrdvars(value, HEALTH_CONF_MAX_LINE);
}
@@ -870,8 +877,8 @@ static int health_readfile(const char *filename, void *data) {
int error = 0;
rc->warning = expression_parse(value, &failed_at, &error);
if(!rc->warning) {
- error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
- line, filename, rrdcalc_name(rc), key, value, expression_strerror(error), failed_at);
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
+ line, filename, rrdcalc_name(rc), key, value, expression_strerror(error), failed_at);
}
parse_variables_and_store_in_health_rrdvars(value, HEALTH_CONF_MAX_LINE);
}
@@ -881,8 +888,8 @@ static int health_readfile(const char *filename, void *data) {
int error = 0;
rc->critical = expression_parse(value, &failed_at, &error);
if(!rc->critical) {
- error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
- line, filename, rrdcalc_name(rc), key, value, expression_strerror(error), failed_at);
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
+ line, filename, rrdcalc_name(rc), key, value, expression_strerror(error), failed_at);
}
parse_variables_and_store_in_health_rrdvars(value, HEALTH_CONF_MAX_LINE);
}
@@ -890,8 +897,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->exec = string_strdupz(value);
if(rc->exec) {
if(strcmp(rrdcalc_exec(rc), 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').",
- line, filename, rrdcalc_name(rc), key, rrdcalc_exec(rc), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalc_name(rc), key, rrdcalc_exec(rc), value, value);
string_freez(rc->exec);
}
@@ -901,8 +908,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->to = string_strdupz(value);
if(rc->recipient) {
if(strcmp(rrdcalc_recipient(rc), 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').",
- line, filename, rrdcalc_name(rc), key, rrdcalc_recipient(rc), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalc_name(rc), key, rrdcalc_recipient(rc), value, value);
string_freez(rc->recipient);
}
@@ -914,8 +921,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->units = string_strdupz(value);
if(rc->units) {
if(strcmp(rrdcalc_units(rc), 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').",
- line, filename, rrdcalc_name(rc), key, rrdcalc_units(rc), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalc_name(rc), key, rrdcalc_units(rc), value, value);
string_freez(rc->units);
}
@@ -927,8 +934,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->info = string_strdupz(value);
if(rc->info) {
if(strcmp(rrdcalc_info(rc), 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').",
- line, filename, rrdcalc_name(rc), key, rrdcalc_info(rc), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalc_name(rc), key, rrdcalc_info(rc), value, value);
string_freez(rc->info);
string_freez(rc->original_info);
@@ -954,8 +961,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->host_labels = string_strdupz(value);
if(rc->host_labels) {
if(strcmp(rrdcalc_host_labels(rc), 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'.",
- line, filename, rrdcalc_name(rc), key, value, value);
+ netdata_log_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'.",
+ line, filename, rrdcalc_name(rc), key, value, value);
string_freez(rc->host_labels);
simple_pattern_free(rc->host_labels_pattern);
@@ -989,8 +996,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->chart_labels = string_strdupz(value);
if(rc->chart_labels) {
if(strcmp(rrdcalc_chart_labels(rc), 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'.",
- line, filename, rrdcalc_name(rc), key, value, value);
+ netdata_log_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'.",
+ line, filename, rrdcalc_name(rc), key, value, value);
string_freez(rc->chart_labels);
simple_pattern_free(rc->chart_labels_pattern);
@@ -1007,8 +1014,8 @@ static int health_readfile(const char *filename, void *data) {
true);
}
else {
- error("Health configuration at line %zu of file '%s' for alarm '%s' has unknown key '%s'.",
- line, filename, rrdcalc_name(rc), key);
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has unknown key '%s'.",
+ line, filename, rrdcalc_name(rc), key);
}
}
else if(rt) {
@@ -1016,8 +1023,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->on = string_strdupz(value);
if(rt->context) {
if(strcmp(string2str(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').",
- line, filename, rrdcalctemplate_name(rt), key, string2str(rt->context), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalctemplate_name(rt), key, string2str(rt->context), value, value);
string_freez(rt->context);
}
@@ -1029,8 +1036,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->classification = string_strdupz(value);
if(rt->classification) {
if(strcmp(rrdcalctemplate_classification(rt), 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').",
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_classification(rt), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_classification(rt), value, value);
string_freez(rt->classification);
}
@@ -1042,8 +1049,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->component = string_strdupz(value);
if(rt->component) {
if(strcmp(rrdcalctemplate_component(rt), 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').",
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_component(rt), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_component(rt), value, value);
string_freez(rt->component);
}
@@ -1055,8 +1062,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->type = string_strdupz(value);
if(rt->type) {
if(strcmp(rrdcalctemplate_type(rt), 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').",
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_type(rt), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_type(rt), value, value);
string_freez(rt->type);
}
@@ -1122,8 +1129,8 @@ static int health_readfile(const char *filename, void *data) {
else if(hash == hash_every && !strcasecmp(key, HEALTH_EVERY_KEY)) {
alert_cfg->every = string_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, rrdcalctemplate_name(rt), key, value);
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' cannot parse duration: '%s'.",
+ line, filename, rrdcalctemplate_name(rt), key, value);
alert_cfg->p_update_every = rt->update_every;
}
else if(hash == hash_green && !strcasecmp(key, HEALTH_GREEN_KEY)) {
@@ -1131,8 +1138,8 @@ static int health_readfile(const char *filename, void *data) {
char *e;
rt->green = str2ndd(value, &e);
if(e && *e) {
- error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' leaves this string unmatched: '%s'.",
- line, filename, rrdcalctemplate_name(rt), key, e);
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' leaves this string unmatched: '%s'.",
+ line, filename, rrdcalctemplate_name(rt), key, e);
}
}
else if(hash == hash_red && !strcasecmp(key, HEALTH_RED_KEY)) {
@@ -1140,8 +1147,8 @@ static int health_readfile(const char *filename, void *data) {
char *e;
rt->red = str2ndd(value, &e);
if(e && *e) {
- error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' leaves this string unmatched: '%s'.",
- line, filename, rrdcalctemplate_name(rt), key, e);
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' leaves this string unmatched: '%s'.",
+ line, filename, rrdcalctemplate_name(rt), key, e);
}
}
else if(hash == hash_calc && !strcasecmp(key, HEALTH_CALC_KEY)) {
@@ -1150,8 +1157,8 @@ static int health_readfile(const char *filename, void *data) {
int error = 0;
rt->calculation = expression_parse(value, &failed_at, &error);
if(!rt->calculation) {
- error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
- line, filename, rrdcalctemplate_name(rt), key, value, expression_strerror(error), failed_at);
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
+ line, filename, rrdcalctemplate_name(rt), key, value, expression_strerror(error), failed_at);
}
parse_variables_and_store_in_health_rrdvars(value, HEALTH_CONF_MAX_LINE);
}
@@ -1161,8 +1168,8 @@ static int health_readfile(const char *filename, void *data) {
int error = 0;
rt->warning = expression_parse(value, &failed_at, &error);
if(!rt->warning) {
- error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
- line, filename, rrdcalctemplate_name(rt), key, value, expression_strerror(error), failed_at);
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
+ line, filename, rrdcalctemplate_name(rt), key, value, expression_strerror(error), failed_at);
}
parse_variables_and_store_in_health_rrdvars(value, HEALTH_CONF_MAX_LINE);
}
@@ -1172,8 +1179,8 @@ static int health_readfile(const char *filename, void *data) {
int error = 0;
rt->critical = expression_parse(value, &failed_at, &error);
if(!rt->critical) {
- error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
- line, filename, rrdcalctemplate_name(rt), key, value, expression_strerror(error), failed_at);
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
+ line, filename, rrdcalctemplate_name(rt), key, value, expression_strerror(error), failed_at);
}
parse_variables_and_store_in_health_rrdvars(value, HEALTH_CONF_MAX_LINE);
}
@@ -1181,8 +1188,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->exec = string_strdupz(value);
if(rt->exec) {
if(strcmp(rrdcalctemplate_exec(rt), 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').",
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_exec(rt), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_exec(rt), value, value);
string_freez(rt->exec);
}
@@ -1192,8 +1199,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->to = string_strdupz(value);
if(rt->recipient) {
if(strcmp(rrdcalctemplate_recipient(rt), 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').",
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_recipient(rt), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_recipient(rt), value, value);
string_freez(rt->recipient);
}
@@ -1205,8 +1212,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->units = string_strdupz(value);
if(rt->units) {
if(strcmp(rrdcalctemplate_units(rt), 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').",
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_units(rt), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_units(rt), value, value);
string_freez(rt->units);
}
@@ -1218,8 +1225,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->info = string_strdupz(value);
if(rt->info) {
if(strcmp(rrdcalctemplate_info(rt), 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').",
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_info(rt), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_info(rt), value, value);
string_freez(rt->info);
}
@@ -1243,8 +1250,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->host_labels = string_strdupz(value);
if(rt->host_labels) {
if(strcmp(rrdcalctemplate_host_labels(rt), 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').",
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_host_labels(rt), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_host_labels(rt), value, value);
string_freez(rt->host_labels);
simple_pattern_free(rt->host_labels_pattern);
@@ -1263,8 +1270,8 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->chart_labels = string_strdupz(value);
if(rt->chart_labels) {
if(strcmp(rrdcalctemplate_chart_labels(rt), 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').",
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_chart_labels(rt), value, value);
+ netdata_log_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').",
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_chart_labels(rt), value, value);
string_freez(rt->chart_labels);
simple_pattern_free(rt->chart_labels_pattern);
@@ -1281,13 +1288,13 @@ static int health_readfile(const char *filename, void *data) {
SIMPLE_PATTERN_EXACT, true);
}
else {
- error("Health configuration at line %zu of file '%s' for template '%s' has unknown key '%s'.",
- line, filename, rrdcalctemplate_name(rt), key);
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' has unknown key '%s'.",
+ line, filename, rrdcalctemplate_name(rt), key);
}
}
else {
- error("Health configuration at line %zu of file '%s' has unknown key '%s'. Expected either '" HEALTH_ALARM_KEY "' or '" HEALTH_TEMPLATE_KEY "'.",
- line, filename, key);
+ netdata_log_error("Health configuration at line %zu of file '%s' has unknown key '%s'. Expected either '" HEALTH_ALARM_KEY "' or '" HEALTH_TEMPLATE_KEY "'.",
+ line, filename, key);
}
}
@@ -1321,7 +1328,7 @@ 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.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));
+ netdata_log_debug(D_HEALTH, "CONFIG health is not enabled for host '%s'", rrdhost_hostname(host));
return;
}
@@ -1329,7 +1336,7 @@ void health_readdir(RRDHOST *host, const char *user_path, const char *stock_path
CONFIG_BOOLEAN_YES);
if (!stock_enabled) {
- log_health("[%s]: Netdata will not load stock alarms.", rrdhost_hostname(host));
+ netdata_log_health("[%s]: Netdata will not load stock alarms.", rrdhost_hostname(host));
stock_path = user_path;
}
@@ -1337,6 +1344,6 @@ void health_readdir(RRDHOST *host, const char *user_path, const char *stock_path
health_rrdvars = health_rrdvariables_create();
recursive_config_double_dir_load(user_path, stock_path, subpath, health_readfile, (void *) host, 0);
- log_health("[%s]: Read health configuration.", rrdhost_hostname(host));
+ netdata_log_health("[%s]: Read health configuration.", rrdhost_hostname(host));
sql_store_hashes = 0;
}