Skip to content

Commit

Permalink
move parent host check near host check
Browse files Browse the repository at this point in the history
  • Loading branch information
tsadpbb committed Nov 22, 2024
1 parent 263c706 commit 1800442
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions base/notifications.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,23 +397,6 @@ int check_service_notification_viability(service *svc, int type, int options) {
}
}

/* 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;

for(temp_hostsmember = temp_host->parent_hosts; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
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;
}
}


/* if the service has no notification period, inherit one from the host */
temp_period = svc->notification_period_ptr;
if(temp_period == NULL) {
Expand Down Expand Up @@ -631,6 +614,22 @@ int check_service_notification_viability(service *svc, int type, int options) {
return ERROR;
}

/* 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;

for(temp_hostsmember = temp_host->parent_hosts; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
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) {
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "We haven't waited long enough to re-notify contacts about this service.\n");
Expand Down

0 comments on commit 1800442

Please sign in to comment.