Skip to content

Commit

Permalink
suppress only normal notifications from service parents
Browse files Browse the repository at this point in the history
This change makes service parents work more like service dependencies. Previously
service parents simply dropped all notifications which leads to some issues:

- if a service goes down, sends a notification but comes up before the parent, no recover will be sent
- forced notifications, downtimes etc won't send a notification

With this change only "normal" notifications will be suppressed if all parents are down. But the following
notifications will still be sent:

- custom notifications
- acknowlegements
- flapping alerts
- downtime alerts

Signed-off-by: Sven Nierlein <[email protected]>
  • Loading branch information
sni committed Jan 31, 2024
1 parent d8e1f42 commit f01483f
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/naemon/notifications.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,18 +608,6 @@ int check_service_notification_viability(service *svc, int type, int options)

temp_host = svc->host_ptr;

/* if all parents are bad (usually just one), we shouldn't notify */
if (svc->parents) {
sm = svc->parents;
while (sm && sm->service_ptr->current_state != STATE_OK) {
sm = sm->next;
}
if (sm == NULL) {
LOG_SERVICE_NSR(NSR_BAD_PARENTS);
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 @@ -669,7 +657,6 @@ int check_service_notification_viability(service *svc, int type, int options)
}



/****************************************/
/*** SPECIAL CASE FOR ACKNOWLEGEMENTS ***/
/****************************************/
Expand All @@ -687,7 +674,6 @@ int check_service_notification_viability(service *svc, int type, int options)
return OK;
}


/****************************************/
/*** SPECIAL CASE FOR FLAPPING ALERTS ***/
/****************************************/
Expand Down Expand Up @@ -735,6 +721,21 @@ int check_service_notification_viability(service *svc, int type, int options)
return OK;
}

/******************************************************/
/*** CHECK SERVICE PARENTS FOR NORMAL NOTIFICATIONS ***/
/******************************************************/
/* if all parents are bad (usually just one), we shouldn't notify */
/* but do not prevent recovery notifications */
if (svc->parents && svc->current_state != STATE_OK) {
sm = svc->parents;
while (sm && sm->service_ptr->current_state != STATE_OK) {
sm = sm->next;
}
if (sm == NULL) {
LOG_SERVICE_NSR(NSR_BAD_PARENTS);
return ERROR;
}
}

/****************************************/
/*** NORMAL NOTIFICATIONS ***************/
Expand Down

0 comments on commit f01483f

Please sign in to comment.