#define RRDVAR_MAX_LENGTH 1024
-int health_enabled = 1;
+int default_localhost_health_enabled = 1;
// ----------------------------------------------------------------------------
// RRDVAR management
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;
}
}
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);
}
// 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);
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);
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