@@ -614,19 +614,21 @@ int check_service_notification_viability(service *svc, int type, int options) {
614
614
return ERROR ;
615
615
}
616
616
617
- /* If any of the parents are down, don't notify */
617
+ /* If all of the host parents are down, don't notify */
618
618
if (temp_host -> parent_hosts != NULL ) {
619
+ int bad_parents = 0 , total_parents = 0 ;
619
620
hostsmember * temp_hostsmember = NULL ;
620
- host * parent_host = NULL ;
621
621
622
622
for (temp_hostsmember = temp_host -> parent_hosts ; temp_hostsmember != NULL ; temp_hostsmember = temp_hostsmember -> next ) {
623
- parent_host = temp_hostsmember -> host_ptr ;
624
- if (parent_host -> current_state != HOST_UP ) {
625
- log_debug_info (DEBUGL_NOTIFICATIONS , 1 , "At least one parent (%s) is down, so we won't notify about this service.\n" , parent_host -> name );
626
- return ERROR ;
623
+ if (temp_hostsmember -> host_ptr -> current_state != HOST_UP )
624
+ bad_parents += !!temp_hostsmember -> host_ptr -> current_state ;
625
+ total_parents ++ ;
626
+ }
627
+ if (bad_parents == total_parents ) {
628
+ log_debug_info (DEBUGL_NOTIFICATIONS , 1 , "This service has a host with no good parents, so notification will be blocked.\n" );
629
+ return ERROR ;
627
630
}
628
631
}
629
- }
630
632
631
633
/* don't notify if we haven't waited long enough since the last time (and the service is not marked as being volatile) */
632
634
if ((current_time < svc -> next_notification ) && svc -> is_volatile == FALSE) {
@@ -1538,20 +1540,6 @@ int check_host_notification_viability(host *hst, int type, int options) {
1538
1540
return ERROR ;
1539
1541
}
1540
1542
1541
- /* If any of the parents are down, don't notify */
1542
- if (hst -> parent_hosts != NULL ) {
1543
- hostsmember * temp_hostsmember = NULL ;
1544
- host * parent_host = NULL ;
1545
-
1546
- for (temp_hostsmember = hst -> parent_hosts ; temp_hostsmember != NULL ; temp_hostsmember = temp_hostsmember -> next ) {
1547
- parent_host = temp_hostsmember -> host_ptr ;
1548
- if (parent_host -> current_state != HOST_UP ) {
1549
- log_debug_info (DEBUGL_NOTIFICATIONS , 1 , "At least one parent (%s) is down, so we won't notify about this host.\n" , parent_host -> name );
1550
- return ERROR ;
1551
- }
1552
- }
1553
- }
1554
-
1555
1543
return OK ;
1556
1544
}
1557
1545
0 commit comments