[icinga-checkins] icinga.org: icinga-core/r1.6: core: determine last_program_stop from creation of retention. dat and use that for decision if passive checks are fresh or not ( Andreas Ericsson) #2027

git at icinga.org git at icinga.org
Wed Nov 9 16:43:12 CET 2011


Module: icinga-core
Branch: r1.6
Commit: c87602986e71d5a15ddd5d0de96e0c3bc6992b40
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=c87602986e71d5a15ddd5d0de96e0c3bc6992b40

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Sat Oct 22 16:52:24 2011 +0200

core: determine last_program_stop from creation of retention.dat and use that for decision if passive checks are fresh or not (Andreas Ericsson) #2027

please check the issue for deeper analysis and description.
https://dev.icinga.org/issues/2027

refs #2027

---

 Changelog          |    1 +
 base/checks.c      |   37 +++++++++++++++++++++++++++++++++++++
 base/icinga.c      |    1 +
 xdata/xrddefault.c |    4 ++++
 4 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/Changelog b/Changelog
index b9b171f..4d5d7fd 100644
--- a/Changelog
+++ b/Changelog
@@ -12,6 +12,7 @@ ENHANCEMENTS
 * core: log error on non-existing host/service/contact/*group when sending a command to the core #1737
 * core: reduce notification load by moving notification viability check into notification list creation (Opsview Team) #1744
 * core: protect downtime and comment list modification with a lock (Andreas Ericsson) #2025
+* core: determine last_program_stop from creation of retention.dat and use that for decision if passive checks are fresh or not (Andreas Ericsson) #2027
 
 * classic ui: add expiry option and end_time to acknowledgements on cmd.cgi #770
 
diff --git a/base/checks.c b/base/checks.c
index 583fb2e..cc6c32b 100644
--- a/base/checks.c
+++ b/base/checks.c
@@ -101,6 +101,7 @@ extern int      child_processes_fork_twice;
 extern int      stalking_event_handlers_for_hosts;
 extern int      stalking_event_handlers_for_services;
 
+extern time_t   last_program_stop;
 extern time_t   program_start;
 extern time_t   event_start;
 
@@ -2260,6 +2261,23 @@ int is_service_result_fresh(service *temp_service, time_t current_time, int log_
 	else
 		expiration_time = (time_t)(temp_service->last_check + freshness_threshold);
 
+	/*
+	 * ADDED 22-10-2011 MF, Patch by Andreas Ericsson
+	 * If the check was last done passively, we assume it's going
+	 * to continue that way and we need to handle the fact that
+	 * Icinga might have been shut off for quite a long time. If so,
+	 * we mustn't spam freshness notifications but use program_start_time
+	 * instead of last_check to determine freshness expiration time.
+	 * The threshold for "long time" is determined as 61.8% of the normal
+	 * freshness threshold based on vast heuristical research (ie, "some
+	 * guy once told me the golden ratio is good for loads of stuff").
+	 */
+	if (temp_service->check_type == SERVICE_CHECK_PASSIVE) {
+		if (event_start < program_start + 60 &&	event_start - last_program_stop < (freshness_threshold * 0.618)) {
+			expiration_time = event_start + freshness_threshold;
+		}
+	}
+
 	log_debug_info(DEBUGL_CHECKS, 2, "HBC: %d, PS: %lu, ES: %lu, LC: %lu, CT: %lu, ET: %lu\n", temp_service->has_been_checked, (unsigned long)program_start, (unsigned long)event_start, (unsigned long)temp_service->last_check, (unsigned long)current_time, (unsigned long)expiration_time);
 
 	/* the results for the last check of this service are stale */
@@ -2663,6 +2681,25 @@ int is_host_result_fresh(host *temp_host, time_t current_time, int log_this) {
 	else
 		expiration_time = (time_t)(temp_host->last_check + freshness_threshold);
 
+        /*
+         * ADDED 22-10-2011 MF, Patch by Andreas Ericsson
+         * If the check was last done passively, we assume it's going
+         * to continue that way and we need to handle the fact that
+         * Icinga might have been shut off for quite a long time. If so,
+         * we mustn't spam freshness notifications but use program_start_time
+         * instead of last_check to determine freshness expiration time.
+         * The threshold for "long time" is determined as 61.8% of the normal
+         * freshness threshold based on vast heuristical research (ie, "some
+         * guy once told me the golden ratio is good for loads of stuff").
+         */
+	if (temp_host->check_type == HOST_CHECK_PASSIVE) {
+		if (event_start < program_start + 60 &&
+			event_start - last_program_stop < (freshness_threshold * 0.618))
+		{
+			expiration_time = event_start + freshness_threshold;
+		}
+	}
+
 	log_debug_info(DEBUGL_CHECKS, 2, "HBC: %d, PS: %lu, ES: %lu, LC: %lu, CT: %lu, ET: %lu\n", temp_host->has_been_checked, (unsigned long)program_start, (unsigned long)event_start, (unsigned long)temp_host->last_check, (unsigned long)current_time, (unsigned long)expiration_time);
 
 	/* the results for the last check of this host are stale */
diff --git a/base/icinga.c b/base/icinga.c
index e1353dc..707f8bc 100644
--- a/base/icinga.c
+++ b/base/icinga.c
@@ -142,6 +142,7 @@ int             additional_freshness_latency = DEFAULT_ADDITIONAL_FRESHNESS_LATE
 time_t          last_command_check = 0L;
 time_t          last_command_status_update = 0L;
 time_t          last_log_rotation = 0L;
+time_t          last_program_stop = 0L;
 
 int             use_aggressive_host_checking = DEFAULT_AGGRESSIVE_HOST_CHECKING;
 unsigned long   cached_host_check_horizon = DEFAULT_CACHED_HOST_CHECK_HORIZON;
diff --git a/xdata/xrddefault.c b/xdata/xrddefault.c
index 9b40b5d..f75e9a8 100644
--- a/xdata/xrddefault.c
+++ b/xdata/xrddefault.c
@@ -73,6 +73,8 @@ extern int	      dump_retained_host_service_states_to_neb;
 extern int            use_retained_scheduling_info;
 extern int            retention_scheduling_horizon;
 
+extern time_t         last_program_stop;
+
 extern unsigned long  next_comment_id;
 extern unsigned long  next_downtime_id;
 extern unsigned long  next_event_id;
@@ -1119,6 +1121,8 @@ int xrddefault_read_retention_file_information(char *retention_file, int overwri
 						scheduling_info_is_ok = TRUE;
 					else
 						scheduling_info_is_ok = FALSE;
+					/* save that for determining freshness of checkresults on startup */
+					last_program_stop = creation_time;
 				} else if (!strcmp(var, "version")) {
 				}
 				break;





More information about the icinga-checkins mailing list