Bug - Double Log Rotates

stephane grundsch at users.sourceforge.net
Tue Sep 20 23:05:15 CEST 2005


Hello,

I'm a little bit late, but I've seen in the archive the mail from Scott  
Brynen ( http://sourceforge.net/mailarchive/message.php?msg_id=9215796  
) about the double log rotation bug when the system clock is  
compensated backward.

I still have the same problem (Nagios v1.2), and I thought the simple  
following patch could help. (Or has this been handled in v2.0, or  
anywhere else?)

The idea is quite simple, just do not adjust log rotation events (as  
they must occur at an absolute time, not relative). It's one more "if",  
following diff with context:

nagios-1.2/base # diff -c nagios.c.old nagios.c
*** nagios.c.old        Tue Sep 20 18:16:05 2005
--- nagios.c    Tue Sep 20 18:17:44 2005
***************
*** 1827,1846 ****
         /* adjust the next run time for all high priority timed events  
*/
          
for(temp_event=event_list_high;temp_event!=NULL;temp_event=temp_event- 
 >next){

!               /* we moved back in time... */
!               if(last_time>current_time){
!
!                       /* we can't precede the UNIX epoch */
!                       if(time_difference>(unsigned  
long)temp_event->run_time)
!                               temp_event->run_time=(time_t)0;
!                       else
!                                
temp_event->run_time=(time_t)(temp_event->run_time- 
(time_t)time_difference);
!                       }
!
!               /* we moved into the future... */
!               else
!                        
temp_event->run_time=(time_t)(temp_event- 
 >run_time+(time_t)time_difference);
!               }

         /* adjust the next run time for all low priority timed events */
          
for(temp_event=event_list_low;temp_event!=NULL;temp_event=temp_event- 
 >next){
--- 1827,1848 ----
         /* adjust the next run time for all high priority timed events  
*/
          
for(temp_event=event_list_high;temp_event!=NULL;temp_event=temp_event- 
 >next){

!         if(temp_event->event_type!=EVENT_LOG_ROTATION){
!           /* we moved back in time... */
!           if(last_time>current_time){
!
!             /* we can't precede the UNIX epoch */
!             if(time_difference>(unsigned long)temp_event->run_time)
!               temp_event->run_time=(time_t)0;
!             else
!                
temp_event->run_time=(time_t)(temp_event->run_time- 
(time_t)time_difference);
!           }
!
!           /* we moved into the future... */
!           else
!              
temp_event->run_time=(time_t)(temp_event- 
 >run_time+(time_t)time_difference);
!         }
!       }

         /* adjust the next run time for all low priority timed events */
          
for(temp_event=event_list_low;temp_event!=NULL;temp_event=temp_event- 
 >next){



Any feedback/flame is welcomed!

Steph



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php




More information about the Developers mailing list