Skip to content

Commit 55ae275

Browse files
authored
Fix: Unreachable status should be notifiable (#1009)
* Fix: Unreachable status should be notifiable * move parent host check near host check * Make sure gprof is added
1 parent 1867ffe commit 55ae275

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
run: |
2020
sudo apt update
2121
sudo apt remove libgd3 nginx
22-
sudo apt install libgd-dev valgrind
22+
sudo apt install libgd-dev valgrind binutils
2323
- name: configure
2424
run: ./configure --enable-testing
2525
- name: Run Tests

Changelog

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Nagios Core 4 Change Log
33
########################
44

5+
4.5.9 - 2024-XX-XX
6+
------------------
7+
* Fix unreachable notifications (Dylan Anderson)
8+
59
4.5.8 - 2024-11-19
610
------------------
711
* Improve new exfoliation theme and add back in PID information (Dylan Anderson)

base/notifications.c

+9-21
Original file line numberDiff line numberDiff line change
@@ -614,19 +614,21 @@ int check_service_notification_viability(service *svc, int type, int options) {
614614
return ERROR;
615615
}
616616

617-
/* If any of the parents are down, don't notify */
617+
/* If all of the host parents are down, don't notify */
618618
if (temp_host->parent_hosts != NULL) {
619+
int bad_parents = 0, total_parents = 0;
619620
hostsmember *temp_hostsmember = NULL;
620-
host *parent_host = NULL;
621621

622622
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;
627630
}
628631
}
629-
}
630632

631633
/* don't notify if we haven't waited long enough since the last time (and the service is not marked as being volatile) */
632634
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) {
15381540
return ERROR;
15391541
}
15401542

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-
15551543
return OK;
15561544
}
15571545

0 commit comments

Comments
 (0)