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

+

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).

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.