[Nagios-checkins] nagios/base checks.c, 1.170, 1.171 nagios.c, 1.172, 1.173 utils.c, 1.245, 1.246

Ethan Galstad egalstad at users.sourceforge.net
Tue Aug 11 16:53:06 UTC 2009


Update of /cvsroot/nagios/nagios/base
In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10490/base

Modified Files:
	checks.c nagios.c utils.c 
Log Message:
Fix for incorrect service check re-scheduling when timeperiods change between Nagios restarts

Index: nagios.c
===================================================================
RCS file: /cvsroot/nagios/nagios/base/nagios.c,v
retrieving revision 1.172
retrieving revision 1.173
diff -C2 -d -r1.172 -r1.173
*** nagios.c	31 Jul 2009 16:54:20 -0000	1.172
--- nagios.c	11 Aug 2009 16:53:04 -0000	1.173
***************
*** 607,610 ****
--- 607,625 ----
  		        }
  
+ #undef TEST_TIMEPERIODS
+ #ifdef TEST_TIMEPERIODS
+ 		/* DO SOME TIMEPERIOD TESTING - ADDED 08/11/2009 */
+ 		time_t now, pref_time, valid_time;
+ 		timeperiod *tp;
+ 		tp=find_timeperiod("247_exclusion");
+ 		time(&now);
+ 		pref_time=now;
+ 		get_next_valid_time(pref_time,&valid_time,tp);
+ 		printf("=====\n");
+ 		printf("CURRENT:   %lu = %s",(unsigned long)now,ctime(&now));
+ 		printf("PREFERRED: %lu = %s",(unsigned long)pref_time,ctime(&pref_time));
+ 		printf("NEXT:      %lu = %s",(unsigned long)valid_time,ctime(&valid_time));
+ 		printf("=====\n");
+ #endif
  
  		/* clean up after ourselves */

Index: utils.c
===================================================================
RCS file: /cvsroot/nagios/nagios/base/utils.c,v
retrieving revision 1.245
retrieving revision 1.246
diff -C2 -d -r1.245 -r1.246
*** utils.c	17 Jun 2009 13:11:04 -0000	1.245
--- utils.c	11 Aug 2009 16:53:04 -0000	1.246
***************
*** 1166,1170 ****
  #endif
  
! 	/**** check exceptions first ****/
  	for(daterange_type=0;daterange_type<DATERANGE_TYPES;daterange_type++){
  
--- 1166,1170 ----
  #endif
  
! 	/**** check exceptions (in this timeperiod definition) first ****/
  	for(daterange_type=0;daterange_type<DATERANGE_TYPES;daterange_type++){
  
***************
*** 1177,1181 ****
  			/* get the start time */
  			switch(daterange_type){
! 			case DATERANGE_CALENDAR_DATE:
  				t->tm_sec=0;
  				t->tm_min=0;
--- 1177,1181 ----
  			/* get the start time */
  			switch(daterange_type){
! 			case DATERANGE_CALENDAR_DATE: /* 2009-08-11 */
  				t->tm_sec=0;
  				t->tm_min=0;
***************
*** 1187,1191 ****
  				start_time=mktime(t);
  				break;
! 			case DATERANGE_MONTH_DATE:
  				/* what year should we use? */
  				year=(pref_time_year < current_time_year)?current_time_year:pref_time_year;
--- 1187,1191 ----
  				start_time=mktime(t);
  				break;
! 			case DATERANGE_MONTH_DATE:  /* january 1 */
  				/* what year should we use? */
  				year=(pref_time_year < current_time_year)?current_time_year:pref_time_year;
***************
*** 1195,1199 ****
  				start_time=calculate_time_from_day_of_month(year,temp_daterange->smon,temp_daterange->smday);
  				break;
! 			case DATERANGE_MONTH_DAY:
  				/* what year should we use? */
  				year=(pref_time_year < current_time_year)?current_time_year:pref_time_year;
--- 1195,1199 ----
  				start_time=calculate_time_from_day_of_month(year,temp_daterange->smon,temp_daterange->smday);
  				break;
! 			case DATERANGE_MONTH_DAY:  /* day 3 */
  				/* what year should we use? */
  				year=(pref_time_year < current_time_year)?current_time_year:pref_time_year;
***************
*** 1212,1216 ****
  				start_time=calculate_time_from_day_of_month(year,month,temp_daterange->smday);
  				break;
! 			case DATERANGE_MONTH_WEEK_DAY:
  				/* what year should we use? */
  				year=(pref_time_year < current_time_year)?current_time_year:pref_time_year;
--- 1212,1216 ----
  				start_time=calculate_time_from_day_of_month(year,month,temp_daterange->smday);
  				break;
! 			case DATERANGE_MONTH_WEEK_DAY: /* thursday 2 april */
  				/* what year should we use? */
  				year=(pref_time_year < current_time_year)?current_time_year:pref_time_year;
***************
*** 1223,1227 ****
  					}
  				break;
! 			case DATERANGE_WEEK_DAY:
  				/* what year should we use? */
  				year=(pref_time_year < current_time_year)?current_time_year:pref_time_year;
--- 1223,1227 ----
  					}
  				break;
! 			case DATERANGE_WEEK_DAY: /* wednesday 1 */
  				/* what year should we use? */
  				year=(pref_time_year < current_time_year)?current_time_year:pref_time_year;
***************
*** 1245,1248 ****
--- 1245,1252 ----
  				}
  
+ #ifdef TEST_TIMEPERIODS_B
+ 			printf("START TIME: %lu = %s",start_time,ctime(&start_time));
+ #endif
+ 
  			/* get the end time */
  			switch(daterange_type){
***************
*** 1439,1443 ****
  
  
! 	/**** find next available time from normal, weekly rotating schedule ****/
  
  	/* check a one week rotation of time */
--- 1443,1447 ----
  
  
! 	/**** find next available time from normal, weekly rotating schedule (in this timeperiod definition) ****/
  
  	/* check a one week rotation of time */

Index: checks.c
===================================================================
RCS file: /cvsroot/nagios/nagios/base/checks.c,v
retrieving revision 1.170
retrieving revision 1.171
diff -C2 -d -r1.170 -r1.171
*** checks.c	23 Jun 2009 17:33:00 -0000	1.170
--- checks.c	11 Aug 2009 16:53:04 -0000	1.171
***************
*** 280,285 ****
  			get_next_valid_time(preferred_time,&next_valid_time,svc->check_period_ptr);
  
  			/* the service could not be rescheduled properly - set the next check time for next week */
! 			if(time_is_valid==FALSE && next_valid_time==preferred_time){
  
  				/*
--- 280,292 ----
  			get_next_valid_time(preferred_time,&next_valid_time,svc->check_period_ptr);
  
+ 			logit(NSLOG_RUNTIME_WARNING,TRUE,"Warning: Service '%s' on host '%s' timeperiod check failed...\n",svc->description,svc->host_name);
+ 			logit(NSLOG_RUNTIME_WARNING,TRUE,"Current time: %s",ctime(&current_time));
+ 			logit(NSLOG_RUNTIME_WARNING,TRUE,"Preferred time: %s",ctime(&preferred_time));
+ 			logit(NSLOG_RUNTIME_WARNING,TRUE,"Next valid time: %s",ctime(&next_valid_time));
+ 
  			/* the service could not be rescheduled properly - set the next check time for next week */
! 			/*if(time_is_valid==FALSE && next_valid_time==preferred_time){*/
! 			/* UPDATED 08/12/09 EG to reflect proper timeperod check logic */
! 			if(time_is_valid==FALSE &&  check_time_against_period(next_valid_time,svc->check_period_ptr)==ERROR){
  
  				/*





More information about the Nagios-commits mailing list