int oldstate, runnable = 0;
time_t now = now_realtime_sec();
+ time_t now_boot = now_boottime_sec();
time_t next_run = now + min_run_every;
RRDCALC *rc;
+ time_t last_now = now;
+ time_t last_now_boot = now_boot;
+ time_t hibernation_delay = config_get_number("health", "postpone alarms during hibernation for seconds", 60);
+
if(unlikely(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate) != 0))
error("Cannot set pthread cancel state to DISABLE.");
RRDHOST *host;
rrdhost_foreach_read(host) {
- if(unlikely(!host->health_enabled)) continue;
+ if(now - last_now > 2 * (now_boot - last_now_boot)) {
+ info("Postponing alarm checks for %ld seconds, on host '%s', due to boottime discrepancy (realtime dt: %ld, boottime dt: %ld).",
+ hibernation_delay, host->hostname, (long)(now - last_now), (long)(now_boot - last_now_boot));
+ host->health_delay_up_to = now + hibernation_delay;
+ }
+ last_now = now;
+ last_now_boot = now_boot;
+
+ if(unlikely(!host->health_enabled || now < host->health_delay_up_to)) continue;
rrdhost_rdlock(host);
}
else
debug(D_HEALTH, "Health monitoring iteration no %u done. Next iteration now", loop);
+
+ now_boot = now_boottime_sec();
}
buffer_free(wb);
int rrd_history_entries; // the number of history entries for the host's charts
int health_enabled; // 1 when this host has health enabled
+ time_t health_delay_up_to; // a timestamp to delay alarms processing up to
RRD_MEMORY_MODE rrd_memory_mode; // the memory more for the charts of this host
RRDSET *rrdset_root; // the host charts
int history = default_rrd_history_entries;
RRD_MEMORY_MODE mode = default_rrd_memory_mode;
int health_enabled = default_health_enabled;
+ time_t alarms_delay = 60;
update_every = (int)appconfig_get_number(&stream_config, machine_guid, "update every", update_every);
if(update_every < 0) update_every = 1;
health_enabled = appconfig_get_boolean_ondemand(&stream_config, key, "health enabled by default", health_enabled);
health_enabled = appconfig_get_boolean_ondemand(&stream_config, machine_guid, "health enabled", health_enabled);
+ alarms_delay = appconfig_get_number(&stream_config, key, "default postpone alarms on connect seconds", alarms_delay);
+ alarms_delay = appconfig_get_number(&stream_config, machine_guid, "postpone alarms on connect seconds", alarms_delay);
+
if(!strcmp(machine_guid, "localhost"))
host = localhost;
else
rrdhost_wrlock(host);
host->use_counter++;
+ if(health_enabled != CONFIG_BOOLEAN_NO)
+ host->health_delay_up_to = now_realtime_sec() + alarms_delay;
rrdhost_unlock(host);
// call the plugins.d processor to receive the metrics