Skip to content

Commit

Permalink
Fix: Unreachable status should be notifiable (#1009)
Browse files Browse the repository at this point in the history
* Fix: Unreachable status should be notifiable

* move parent host check near host check

* Make sure gprof is added
  • Loading branch information
tsadpbb authored Dec 2, 2024
1 parent 1867ffe commit 55ae275
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 9 additions & 21 deletions base/notifications.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 55ae275

Please sign in to comment.