diff -ur nagios-2.9.original/Makefile.in nagios-2.9/Makefile.in --- nagios-2.9.original/Makefile.in 2007-02-12 22:16:42.000000000 +0000 +++ nagios-2.9/Makefile.in 2007-06-20 17:49:13.000000000 +0100 @@ -14,6 +14,7 @@ SRC_COMMON=@srcdir@/common SRC_XDATA=@srcdir@/xdata SRC_CONTRIB=@srcdir@/contrib +SRC_TESTS=@srcdir@/t CC=@CC@ CFLAGS=@CFLAGS@ @DEFS@ @@ -42,12 +43,15 @@ CP=@CP@ +HAVE_LIBTAP=@HAVE_LIBTAP@ + @SET_MAKE@ none: @echo "Please supply a command line argument (i.e. 'make all'). Other targets are:" - @echo " nagios cgis contrib modules" + @echo " nagios cgis contrib modules tests" @echo " clean" + @echo " test" @echo " install install-base install-cgis install-html install-config install-init install-commandmode fullinstall" # @echo " uninstall" @@ -58,6 +62,7 @@ cd $(SRC_CGI) && $(MAKE) cd $(SRC_HTM) && $(MAKE) cd $(SRC_MODULE) && $(MAKE) + if [ "x$(HAVE_LIBTAP)" = x1 ] ; then cd $(SRC_TESTS) && $(MAKE) ; fi @echo "" @echo "*** Compile finished ***" @@ -132,6 +137,12 @@ modules: cd $(SRC_MODULE) && $(MAKE) +tests: + cd $(SRC_TESTS) && $(MAKE) + +test: + @if [ "x$(HAVE_LIBTAP)" = x1 ] ; then cd $(SRC_TESTS) && $(MAKE) $@ ; else echo "Cannot run tests - please install libtap" ; fi + clean: cd $(SRC_BASE) && $(MAKE) $@ cd $(SRC_CGI) && $(MAKE) $@ @@ -153,6 +164,7 @@ cd $(SRC_INCLUDE) && $(MAKE) $@ cd $(SRC_CONTRIB) && $(MAKE) $@ cd $(SRC_MODULE) && $(MAKE) $@ + cd $(SRC_TESTS) && $(MAKE) $@ rm -f sample-config/*.cfg sample-config/*.conf sample-config/template-object/*.cfg rm -f daemon-init pkginfo rm -f Makefile subst diff -ur nagios-2.9.original/base/Makefile.in nagios-2.9/base/Makefile.in --- nagios-2.9.original/base/Makefile.in 2006-05-30 17:31:44.000000000 +0100 +++ nagios-2.9/base/Makefile.in 2007-06-20 17:51:32.000000000 +0100 @@ -115,7 +115,7 @@ DDATADEPS=$(DDATALIBS) -OBJS=$(BROKER_O) checks.o config.o commands.o events.o flapping.o logging.o notifications.o sehandlers.o utils.o $(RDATALIBS) $(CDATALIBS) $(ODATALIBS) $(SDATALIBS) $(PDATALIBS) $(DDATALIBS) $(BASEEXTRALIBS) $(SNPRINTF_O) $(PERLXSI_O) +OBJS=$(BROKER_O) checks.o config.o commands.o events.o flapping.o freshness.o logging.o notifications.o sehandlers.o utils.o $(RDATALIBS) $(CDATALIBS) $(ODATALIBS) $(SDATALIBS) $(PDATALIBS) $(DDATALIBS) $(BASEEXTRALIBS) $(SNPRINTF_O) $(PERLXSI_O) OBJDEPS=$(ODATADEPS) $(ODATADEPS) $(RDATADEPS) $(CDATADEPS) $(SDATADEPS) $(PDATADEPS) $(DDATADEPS) $(BROKER_H) all: nagios nagiostats diff -ur nagios-2.9.original/base/checks.c nagios-2.9/base/checks.c --- nagios-2.9.original/base/checks.c 2007-04-10 15:50:22.000000000 +0100 +++ nagios-2.9/base/checks.c 2007-06-20 17:35:05.000000000 +0100 @@ -1754,27 +1754,12 @@ printf("CHECKFRESHNESS 3\n"); #endif - /* use user-supplied freshness threshold or auto-calculate a freshness threshold to use? */ - if(temp_service->freshness_threshold==0){ - if(temp_service->state_type==HARD_STATE || temp_service->current_state==STATE_OK) - freshness_threshold=(temp_service->check_interval*interval_length)+temp_service->latency+15; - else - freshness_threshold=(temp_service->retry_interval*interval_length)+temp_service->latency+15; - } + freshness_threshold = calculate_service_freshness_threshold(temp_service); + if (temp_service->has_been_checked==TRUE) + expiration_time = (time_t)(temp_service->last_check + freshness_threshold); else - freshness_threshold=temp_service->freshness_threshold; + expiration_time = (time_t)(program_start + freshness_threshold); -#ifdef TEST_FRESHNESS - printf("THRESHOLD: SVC=%d, USE=%d\n",temp_service->freshness_threshold,freshness_threshold); -#endif - - /* calculate expiration time */ - /* CHANGED 11/10/05 EG - program start is only used in expiration time calculation if > last check AND active checks are enabled, so active checks can become stale immediately upon program startup */ - /* CHANGED 02/25/06 SG - passive checks also become stale, so remove dependence on active check logic */ - if(temp_service->has_been_checked==FALSE || program_start>temp_service->last_check) - expiration_time=(time_t)(program_start+freshness_threshold); - else - expiration_time=(time_t)(temp_service->last_check+freshness_threshold); #ifdef TEST_FRESHNESS printf("HASBEENCHECKED: %d\n",temp_service->has_been_checked); @@ -1813,7 +1798,6 @@ - /******************************************************************/ /******************* ROUTE/HOST CHECK FUNCTIONS *******************/ /******************************************************************/ @@ -1994,18 +1978,11 @@ if(check_time_against_period(current_time,temp_host->check_period)==ERROR) continue; - /* use user-supplied freshness threshold or auto-calculate a freshness threshold to use? */ - if(temp_host->freshness_threshold==0) - freshness_threshold=(temp_host->check_interval*interval_length)+temp_host->latency+15; - else - freshness_threshold=temp_host->freshness_threshold; - - /* calculate expiration time */ - /* CHANGED 11/10/05 EG - program start is only used in expiration time calculation if > last check AND active checks are enabled, so active checks can become stale immediately upon program startup */ - if(temp_host->has_been_checked==FALSE || (temp_host->checks_enabled==TRUE && (program_start>temp_host->last_check))) - expiration_time=(time_t)(program_start+freshness_threshold); + freshness_threshold = calculate_host_freshness_threshold(temp_host); + if (temp_host->has_been_checked==TRUE) + expiration_time = (time_t)(temp_host->last_check + freshness_threshold); else - expiration_time=(time_t)(temp_host->last_check+freshness_threshold); + expiration_time = (time_t)(program_start + freshness_threshold); /* the results for the last check of this host are stale */ if(expiration_time

+Additional Configuation +

+ +

+The additional_freshness_latency option within the main configuration file adds an additional number of seconds to the checks to allow fine tuning of the configuration +

+ + +

How The Freshness Threshold Works

-Nagios periodically checks the "freshness" of the results for all services that have freshness checking enabled. The freshness_threshold option in each service definition is used to determine how "fresh" the results for each service should be. For example, if you set the freshness_threshold option to 60 for one of your services, Nagios will consider that service to be "stale" if its results are older than 60 seconds (1 minute). If you do not specify a value for the freshness_threshold option (or you set it to zero), Nagios will automatically calculate a "freshness" threshold to use by looking at either the normal_check_interval or retry_check_interval options (depending on what type of state the service is currently in). +Nagios periodically checks the "freshness" of the results for all services that have freshness checking enabled. The freshness_threshold option in each service definition is used to determine how "fresh" the results for each service should be. For example, if you set the freshness_threshold option to 60 for one of your services, Nagios will consider that service to be "stale" if its results are older than 60 seconds (1 minute). If you do not specify a value for the freshness_threshold option (or you set it to zero), Nagios will automatically calculate a "freshness" threshold to use by looking at either the normal_check_interval or retry_check_interval options (depending on what type of state the service is currently in). Nagios will also increase the freshness threshold to cater for latency and whether a restart had occurred (because distributed slaves may lose a regular result during the restart) and also add in an addition number of seconds if additional_freshness_latency has been set.

diff -ur nagios-2.9.original/html/docs/xodtemplate.html nagios-2.9/html/docs/xodtemplate.html --- nagios-2.9.original/html/docs/xodtemplate.html 2006-12-26 18:33:22.000000000 +0000 +++ nagios-2.9/html/docs/xodtemplate.html 2007-06-20 17:47:08.000000000 +0100 @@ -266,7 +266,7 @@ freshness_threshold: -This directive is used to specify the freshness threshold (in seconds) for this host. If you set this directive to a value of 0, Nagios will determine a freshness threshold to use automatically. +This directive is used to specify the freshness threshold (in seconds) for this host. If you set this directive to a value of 0, Nagios will determine a freshness threshold to use automatically. @@ -599,7 +599,7 @@ freshness_threshold: -This directive is used to specify the freshness threshold (in seconds) for this service. If you set this directive to a value of 0, Nagios will determine a freshness threshold to use automatically. +This directive is used to specify the freshness threshold (in seconds) for this service. If you set this directive to a value of 0, Nagios will determine a freshness threshold to use automatically. diff -ur nagios-2.9/base/config.c nagios-2.9.new/base/config.c --- nagios-2.9/base/config.c 2007-09-25 20:20:40.000000000 +0100 +++ nagios-2.9.new/base/config.c 2007-09-25 13:34:47.000000000 +0100 @@ -101,6 +101,7 @@ extern int host_freshness_check_interval; extern int auto_rescheduling_interval; extern int auto_rescheduling_window; +extern int additional_freshness_latency; extern int check_external_commands; extern int check_orphaned_services; @@ -1414,6 +1415,16 @@ else if(!strcmp(variable,"check_result_buffer_slots")) check_result_buffer_slots=atoi(value); + else if(!strcmp(variable,"additional_freshness_latency")){ + strip(value); + additional_freshness_latency=atoi(value); + if(additional_freshness_latency<0){ + strcpy(error_message,"Illegal value for additional_freshness_latency"); + error=TRUE; + break; + } + } + /*** AUTH_FILE VARIABLE USED BY EMBEDDED PERL INTERPRETER ***/ else if(!strcmp(variable,"auth_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ diff -ur nagios-2.9/base/nagios.c nagios-2.9.new/base/nagios.c --- nagios-2.9/base/nagios.c 2007-09-25 20:20:40.000000000 +0100 +++ nagios-2.9.new/base/nagios.c 2007-09-25 13:37:08.000000000 +0100 @@ -100,6 +100,7 @@ double sleep_time=DEFAULT_SLEEP_TIME; int interval_length=DEFAULT_INTERVAL_LENGTH; +int additional_freshness_latency=DEFAULT_ADDITIONAL_FRESHNESS_LATENCY; int service_inter_check_delay_method=ICD_SMART; int host_inter_check_delay_method=ICD_SMART; int service_interleave_factor_method=ILF_SMART; diff -ur nagios-2.9/base/utils.c nagios-2.9.new/base/utils.c --- nagios-2.9/base/utils.c 2007-09-25 20:20:40.000000000 +0100 +++ nagios-2.9.new/base/utils.c 2007-09-25 13:45:17.000000000 +0100 @@ -117,6 +117,7 @@ extern int host_freshness_check_interval; extern int auto_rescheduling_interval; extern int auto_rescheduling_window; +extern int additional_freshness_latency; extern int check_external_commands; extern int check_orphaned_services; @@ -5404,6 +5408,7 @@ host_freshness_check_interval=DEFAULT_FRESHNESS_CHECK_INTERVAL; auto_rescheduling_interval=DEFAULT_AUTO_RESCHEDULING_INTERVAL; auto_rescheduling_window=DEFAULT_AUTO_RESCHEDULING_WINDOW; + additional_freshness_latency=DEFAULT_ADDITIONAL_FRESHNESS_LATENCY; check_external_commands=DEFAULT_CHECK_EXTERNAL_COMMANDS; check_orphaned_services=DEFAULT_CHECK_ORPHANED_SERVICES; diff -ur nagios-2.9/html/docs/configmain.html nagios-2.9.new/html/docs/configmain.html --- nagios-2.9/html/docs/configmain.html 2006-12-21 17:16:24.000000000 +0000 +++ nagios-2.9.new/html/docs/configmain.html 2007-09-25 13:58:33.000000000 +0100 @@ -153,6 +153,7 @@ Service freshness check interval
Host freshness checking option
Host freshness check interval
+Additional freshness checking latency

Date format

@@ -2731,6 +2732,32 @@ This setting determines how often (in seconds) Nagios will periodically check the "freshness" of host check results. If you have disabled host freshness checking (with the check_host_freshness option), this option has no effect. More information on freshness checking can be found here.

+

+ + + + + +
Additional Freshness Check Latency
+

+ +

+ + + + + + + + + +
Format:additional_freshness_latency=<seconds>
Example:additional_freshness_latency=30
+

+ +

+Add in an additional number of seconds for every freshness check performed for both services and hosts. If you have disabled host freshness checking (with the check_host_freshness option) and also disabled service freshness checking (with the check_service_freshness option), this option has no effect. More information on freshness checking can be found here. +

+

diff -ur nagios-2.9/include/nagios.h.in nagios-2.9.new/include/nagios.h.in --- nagios-2.9/include/nagios.h.in 2007-01-08 22:24:13.000000000 +0000 +++ nagios-2.9.new/include/nagios.h.in 2007-09-25 13:35:54.000000000 +0100 @@ -172,6 +173,7 @@ #define DEFAULT_RETENTION_SCHEDULING_HORIZON 900 /* max seconds between program restarts that we will preserve scheduling information */ #define DEFAULT_STATUS_UPDATE_INTERVAL 60 /* seconds between aggregated status data updates */ #define DEFAULT_FRESHNESS_CHECK_INTERVAL 60 /* seconds between service result freshness checks */ +#define DEFAULT_ADDITIONAL_FRESHNESS_LATENCY 15 /* Addittional latency to add into freshness calucations */ #define DEFAULT_AUTO_RESCHEDULING_INTERVAL 30 /* seconds between host and service check rescheduling events */ #define DEFAULT_AUTO_RESCHEDULING_WINDOW 180 /* window of time (in seconds) for which we should reschedule host and service checks */