diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dd537b467..2f90ea76d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: run: | sudo apt update sudo apt remove libgd3 nginx - sudo apt install libgd-dev valgrind + sudo apt install libgd-dev valgrind binutils - name: configure run: ./configure --enable-testing - name: Run Tests diff --git a/Changelog b/Changelog index b025bf421..8449f3ee9 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,10 @@ Nagios Core 4 Change Log ######################## +4.5.9 - 2024-XX-XX +------------------ +* Fix unreachable notifications (Dylan Anderson) + 4.5.8 - 2024-11-19 ------------------ * Improve new exfoliation theme and add back in PID information (Dylan Anderson) diff --git a/base/notifications.c b/base/notifications.c index 4e8786ea5..54efebaca 100644 --- a/base/notifications.c +++ b/base/notifications.c @@ -614,19 +614,21 @@ int check_service_notification_viability(service *svc, int type, int options) { return ERROR; } - /* If any of the parents are down, don't notify */ + /* If all of the host parents are down, don't notify */ if (temp_host->parent_hosts != NULL) { + int bad_parents = 0, total_parents = 0; hostsmember *temp_hostsmember = NULL; - host *parent_host = NULL; for(temp_hostsmember = temp_host->parent_hosts; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) { - parent_host = temp_hostsmember->host_ptr; - if (parent_host->current_state != HOST_UP) { - 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); - return ERROR; + if (temp_hostsmember->host_ptr->current_state != HOST_UP) + bad_parents += !!temp_hostsmember->host_ptr->current_state; + total_parents++; + } + if(bad_parents == total_parents) { + log_debug_info(DEBUGL_NOTIFICATIONS, 1, "This service has a host with no good parents, so notification will be blocked.\n"); + return ERROR; } } - } /* don't notify if we haven't waited long enough since the last time (and the service is not marked as being volatile) */ 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) { return ERROR; } - /* If any of the parents are down, don't notify */ - if (hst->parent_hosts != NULL) { - hostsmember *temp_hostsmember = NULL; - host *parent_host = NULL; - - for(temp_hostsmember = hst->parent_hosts; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) { - parent_host = temp_hostsmember->host_ptr; - if (parent_host->current_state != HOST_UP) { - 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); - return ERROR; - } - } - } - return OK; }