X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fhealth.c;h=bd62fbcf8b7fbb8d3ead594422b15df7a61909d4;hb=35c1abbdc2833089667ffde39813d103e65dd54d;hp=0ef6f718bcbe48f364878bb58b0bbd964b3875c8;hpb=31d02cfae33331b29d915dbe19e5baf3bfd72df8;p=netdata.git diff --git a/src/health.c b/src/health.c index 0ef6f718..bd62fbcf 100644 --- a/src/health.c +++ b/src/health.c @@ -3,7 +3,7 @@ #define RRDVAR_MAX_LENGTH 1024 -int health_enabled = 1; +int default_localhost_health_enabled = 1; // ---------------------------------------------------------------------------- // RRDVAR management @@ -1075,7 +1075,7 @@ inline char *health_config_dir(void) { void health_init(void) { debug(D_HEALTH, "Health configuration initializing"); - if(!(health_enabled = config_get_boolean("health", "enabled", 1))) { + if(!(default_localhost_health_enabled = config_get_boolean("health", "enabled", 1))) { debug(D_HEALTH, "Health is disabled."); return; } @@ -1098,15 +1098,10 @@ inline void health_free_host_nolock(RRDHOST *host) { } void health_reload_host(RRDHOST *host) { - if(!health_enabled) { - error("Health reload is requested, but health is not enabled."); - return; - } - char *path = health_config_dir(); // free all running alarms - rrdhost_rwlock(host); + rrdhost_wrlock(host); health_free_host_nolock(host); rrdhost_unlock(host); @@ -1125,13 +1120,13 @@ void health_reload_host(RRDHOST *host) { } // load the new alarms - rrdhost_rwlock(host); + rrdhost_wrlock(host); health_readdir(host, path); rrdhost_unlock(host); // link the loaded alarms to their charts for(st = host->rrdset_root; st ; st = st->next) { - rrdhost_rwlock(host); + rrdhost_wrlock(host); rrdsetcalc_link_matching(st); rrdcalctemplate_link_matching(st); @@ -1406,7 +1401,7 @@ void *health_main(void *ptr) { BUFFER *wb = buffer_create(100); unsigned int loop = 0; - while(health_enabled && !netdata_exit) { + while(!netdata_exit) { loop++; debug(D_HEALTH, "Health monitoring iteration no %u started", loop); @@ -1420,6 +1415,8 @@ void *health_main(void *ptr) { RRDHOST *host; for(host = localhost; host ; host = host->next) { + if(unlikely(!host->health_enabled)) continue; + rrdhost_rdlock(host); // the first loop is to lookup values from the db