I have tested those modifications on Nagios 3.2.3 source and I think it works better than the original code. The patch keeps the first notification greater then the last  state change, whenever the state changes happens.<br>

<br>Rogerio Cunha.<br><br>--- base/notifications.c    2010-08-04 23:43:53.000000000 -0300<br>+++ base2/notifications.c.4    2011-09-02 16:53:40.139155621 -0300<br>@@ -504,13 +504,9 @@<br> <br>         /* determine the time to use of the first problem point */<br>

         first_problem_time=svc->last_time_ok; /* not accurate, but its the earliest time we could use in the comparison */<br>-        if((svc->last_time_warning < first_problem_time) && (svc->last_time_warning > svc->last_time_ok))<br>

-            first_problem_time=svc->last_time_warning;<br>-        if((svc->last_time_unknown < first_problem_time) && (svc->last_time_unknown > svc->last_time_ok))<br>-            first_problem_time=svc->last_time_unknown;<br>

-        if((svc->last_time_critical < first_problem_time) && (svc->last_time_critical > svc->last_time_ok))<br>-            first_problem_time=svc->last_time_critical;<br>-    <br>+        if((svc->last_hard_state_change > svc->last_time_ok)) { <br>

+            first_problem_time=svc->last_hard_state_change;<br>+        }<br>         if(current_time < (time_t)((first_problem_time==(time_t)0L)?program_start:first_problem_time + (svc->first_notification_delay*interval_length))){<br>

             log_debug_info(DEBUGL_NOTIFICATIONS,1,"Not enough time has elapsed since the service changed to a non-OK state, so we should not notify about this problem yet\n");<br>             return ERROR;<br>
@@ -1393,11 +1389,8 @@<br>
 <br>         /* determine the time to use of the first problem point */<br>         first_problem_time=hst->last_time_up; /* not accurate, but its the earliest time we could use in the comparison */<br>-        if((hst->last_time_down < first_problem_time) && (hst->last_time_down > hst->last_time_up))<br>

-            first_problem_time=hst->last_time_down;<br>-        if((hst->last_time_unreachable < first_problem_time) && (hst->last_time_unreachable > hst->last_time_unreachable))<br>-            first_problem_time=hst->last_time_unreachable;<br>

-    <br>+        if((hst->last_hard_state_change > first_problem_time))<br>+            first_problem_time=hst->last_hard_state_change;<br>         if(current_time < (time_t)((first_problem_time==(time_t)0L)?program_start:first_problem_time + (hst->first_notification_delay*interval_length))){<br>

             log_debug_info(DEBUGL_NOTIFICATIONS,1,"Not enough time has elapsed since the host changed to a non-UP state (or since program start), so we shouldn't notify about this problem yet.\n");<br>             return ERROR;<br>

<br>