summaryrefslogtreecommitdiffstats
path: root/health/health_config.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-04-14 18:12:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-04-14 18:12:14 +0000
commitbb50acdcb8073654ea667b8c0272e335bd43f844 (patch)
tree1e00c8a29871426f8182658928dcb62e42d57ce8 /health/health_config.c
parentReleasing debian version 1.33.1-1. (diff)
downloadnetdata-bb50acdcb8073654ea667b8c0272e335bd43f844.tar.xz
netdata-bb50acdcb8073654ea667b8c0272e335bd43f844.zip
Merging upstream version 1.34.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'health/health_config.c')
-rw-r--r--health/health_config.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/health/health_config.c b/health/health_config.c
index da71f13d..e1f5f0e3 100644
--- a/health/health_config.c
+++ b/health/health_config.c
@@ -538,6 +538,7 @@ static inline void alert_config_free(struct alert_config *cfg)
freez(cfg);
}
+int sql_store_hashes = 1;
static int health_readfile(const char *filename, void *data) {
RRDHOST *host = (RRDHOST *)data;
@@ -662,17 +663,15 @@ static int health_readfile(const char *filename, void *data) {
if(hash == hash_alarm && !strcasecmp(key, HEALTH_ALARM_KEY)) {
if(rc) {
- if(ignore_this || !alert_hash_and_store_config(rc->config_hash_id, alert_cfg) || !rrdcalc_add_alarm_from_config(host, rc)) {
+ if(!alert_hash_and_store_config(rc->config_hash_id, alert_cfg, sql_store_hashes) || ignore_this || !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 || !alert_hash_and_store_config(rt->config_hash_id, alert_cfg) || !rrdcalctemplate_add_template_from_config(host, rt)) {
+ if (!alert_hash_and_store_config(rt->config_hash_id, alert_cfg, sql_store_hashes) || ignore_this || !rrdcalctemplate_add_template_from_config(host, rt)) {
rrdcalctemplate_free(rt);
- alert_config_free(alert_cfg);
}
rt = NULL;
}
@@ -690,6 +689,8 @@ 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;
+ if (alert_cfg)
+ alert_config_free(alert_cfg);
alert_cfg = callocz(1, sizeof(struct alert_config));
if(rrdvar_fix_name(rc->name))
@@ -701,18 +702,16 @@ static int health_readfile(const char *filename, void *data) {
else if(hash == hash_template && !strcasecmp(key, HEALTH_TEMPLATE_KEY)) {
if(rc) {
// health_add_alarms_loop(host, rc, ignore_this) ;
- if(ignore_this || !alert_hash_and_store_config(rc->config_hash_id, alert_cfg) || !rrdcalc_add_alarm_from_config(host, rc)) {
+ if(!alert_hash_and_store_config(rc->config_hash_id, alert_cfg, sql_store_hashes) || ignore_this || !rrdcalc_add_alarm_from_config(host, rc)) {
rrdcalc_free(rc);
- alert_config_free(alert_cfg);
}
rc = NULL;
}
if(rt) {
- if(ignore_this || !alert_hash_and_store_config(rt->config_hash_id, alert_cfg) || !rrdcalctemplate_add_template_from_config(host, rt)) {
+ if(!alert_hash_and_store_config(rt->config_hash_id, alert_cfg, sql_store_hashes) || ignore_this || !rrdcalctemplate_add_template_from_config(host, rt)) {
rrdcalctemplate_free(rt);
- alert_config_free(alert_cfg);
}
}
@@ -725,6 +724,8 @@ 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;
+ if (alert_cfg)
+ alert_config_free(alert_cfg);
alert_cfg = callocz(1, sizeof(struct alert_config));
if(rrdvar_fix_name(rt->name))
@@ -1225,13 +1226,13 @@ static int health_readfile(const char *filename, void *data) {
if(rc) {
//health_add_alarms_loop(host, rc, ignore_this) ;
- if(ignore_this || !alert_hash_and_store_config(rc->config_hash_id, alert_cfg) || !rrdcalc_add_alarm_from_config(host, rc)) {
+ if(!alert_hash_and_store_config(rc->config_hash_id, alert_cfg, sql_store_hashes) || ignore_this || !rrdcalc_add_alarm_from_config(host, rc)) {
rrdcalc_free(rc);
}
}
if(rt) {
- if(ignore_this || !alert_hash_and_store_config(rt->config_hash_id, alert_cfg) || !rrdcalctemplate_add_template_from_config(host, rt)) {
+ if(!alert_hash_and_store_config(rt->config_hash_id, alert_cfg, sql_store_hashes) || ignore_this || !rrdcalctemplate_add_template_from_config(host, rt)) {
rrdcalctemplate_free(rt);
}
}
@@ -1243,6 +1244,11 @@ static int health_readfile(const char *filename, void *data) {
return 1;
}
+void sql_refresh_hashes(void)
+{
+ sql_store_hashes = 1;
+}
+
void health_readdir(RRDHOST *host, const char *user_path, const char *stock_path, const char *subpath) {
if(unlikely(!host->health_enabled)) {
debug(D_HEALTH, "CONFIG health is not enabled for host '%s'", host->hostname);
@@ -1258,4 +1264,5 @@ void health_readdir(RRDHOST *host, const char *user_path, const char *stock_path
}
recursive_config_double_dir_load(user_path, stock_path, subpath, health_readfile, (void *) host, 0);
+ sql_store_hashes = 0;
}