X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fhealth.c;h=57210c77b321344e9a930f1c5489f06543696666;hb=f198b96633b63e15894ddabd01234cdcdbe9b321;hp=9e02b5449b7b45d1bf78223028350b15a4d125ca;hpb=28a441fb4034d81ce9e0cebad354199ac5b8250a;p=netdata.git diff --git a/src/health.c b/src/health.c index 9e02b544..57210c77 100644 --- a/src/health.c +++ b/src/health.c @@ -9,22 +9,15 @@ int default_health_enabled = 1; inline char *health_config_dir(void) { char buffer[FILENAME_MAX + 1]; snprintfz(buffer, FILENAME_MAX, "%s/health.d", netdata_configured_config_dir); - return config_get("health", "health configuration directory", buffer); + return config_get(CONFIG_SECTION_HEALTH, "health configuration directory", buffer); } void health_init(void) { debug(D_HEALTH, "Health configuration initializing"); - if(!rrdpush_exclusive) { - if(!(default_health_enabled = config_get_boolean("health", "enabled", 1))) { - debug(D_HEALTH, "Health is disabled."); - return; - } - } - else { - info("Health is disabled - setup alarms at the central netdata."); - config_set_boolean("health", "enabled", 0); - default_health_enabled = 0; + if(!(default_health_enabled = config_get_boolean(CONFIG_SECTION_HEALTH, "enabled", 1))) { + debug(D_HEALTH, "Health is disabled."); + return; } } @@ -32,6 +25,9 @@ void health_init(void) { // re-load health configuration void health_reload_host(RRDHOST *host) { + if(unlikely(!host->health_enabled)) + return; + char *path = health_config_dir(); // free all running alarms @@ -285,6 +281,16 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run) return 0; } + if(unlikely(rrdset_flag_check(rc->rrdset, RRDSET_FLAG_OBSOLETE))) { + debug(D_HEALTH, "Health not running alarm '%s.%s'. The chart has been marked as obsolete", rc->chart?rc->chart:"NOCHART", rc->name); + return 0; + } + + if(unlikely(!rrdset_flag_check(rc->rrdset, RRDSET_FLAG_ENABLED))) { + debug(D_HEALTH, "Health not running alarm '%s.%s'. The chart is not enabled", rc->chart?rc->chart:"NOCHART", rc->name); + return 0; + } + if(unlikely(!rc->rrdset->last_collected_time.tv_sec || rc->rrdset->counter_done < 2)) { debug(D_HEALTH, "Health not running alarm '%s.%s'. Chart is not fully collected yet.", rc->chart?rc->chart:"NOCHART", rc->name); return 0; @@ -328,7 +334,7 @@ void *health_main(void *ptr) { if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0) error("Cannot set pthread cancel state to ENABLE."); - int min_run_every = (int)config_get_number("health", "run at least every seconds", 10); + int min_run_every = (int)config_get_number(CONFIG_SECTION_HEALTH, "run at least every seconds", 10); if(min_run_every < 1) min_run_every = 1; BUFFER *wb = buffer_create(100); @@ -337,7 +343,7 @@ void *health_main(void *ptr) { time_t now_boottime = now_boottime_sec(); time_t last_now = now; time_t last_now_boottime = now_boottime; - time_t hibernation_delay = config_get_number("health", "postpone alarms during hibernation for seconds", 60); + time_t hibernation_delay = config_get_number(CONFIG_SECTION_HEALTH, "postpone alarms during hibernation for seconds", 60); unsigned int loop = 0; while(!netdata_exit) { @@ -363,6 +369,9 @@ void *health_main(void *ptr) { RRDHOST *host; rrdhost_foreach_read(host) { + if(unlikely(!host->health_enabled)) + continue; + if(unlikely(apply_hibernation_delay)) { info("Postponing alarm checks for %ld seconds, on host '%s', due to boottime discrepancy (realtime dt: %ld, boottime dt: %ld)." @@ -399,18 +408,18 @@ void *health_main(void *ptr) { /* time_t old_db_timestamp = rc->db_before; */ int value_is_null = 0; - int ret = rrd2value(rc->rrdset - , wb - , &rc->value - , rc->dimensions - , 1 - , rc->after - , rc->before - , rc->group - , rc->options - , &rc->db_after - , &rc->db_before - , &value_is_null + int ret = rrdset2value_api_v1(rc->rrdset + , wb + , &rc->value + , rc->dimensions + , 1 + , rc->after + , rc->before + , rc->group + , rc->options + , &rc->db_after + , &rc->db_before + , &value_is_null ); if(unlikely(ret != 200)) {