Skip to content

Commit

Permalink
Update to fix NagiosEnterprises#575 properly to work the same as in o…
Browse files Browse the repository at this point in the history
…ther versions of Core. In order to do this we are moving some of the resetting logic for service OK states so that the notification for soft recovery goes out before setting it to a HARD OK state.
  • Loading branch information
jomann09 authored and msdiamanti committed Feb 28, 2023
1 parent 850086c commit a0c8db5
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions base/checks.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,15 +889,6 @@ static inline void service_state_or_hard_state_type_change(service * svc, int st
next_problem_id++;
}

/* clear the problem id when transitioning from a problem state to an OK state */
if (svc->current_state == STATE_OK && hard_state_change == TRUE) {
svc->last_problem_id = svc->current_problem_id;
svc->current_problem_id = 0L;
svc->current_attempt = 1;
svc->current_notification_number = 0;
svc->host_problem_at_last_check = FALSE;
}

svc->state_type = SOFT_STATE;

state_or_type_change = TRUE;
Expand Down Expand Up @@ -1591,6 +1582,25 @@ int handle_async_service_check_result(service *svc, check_result *cr)
handle_service_event(svc);
}

/* Update OK states since they send out a soft alert but then they
switch into a HARD state and reset the attempts */
if (svc->current_state == STATE_OK && state_change == TRUE) {

/* Reset attempts and problem state */
if (hard_state_change == TRUE) {
svc->last_problem_id = svc->current_problem_id;
svc->current_problem_id = 0L;
svc->current_notification_number = 0;
svc->host_problem_at_last_check = FALSE;
}

/* Set OK to a hard state */
svc->last_hard_state_change = svc->last_check;
svc->last_hard_state = svc->current_state;
svc->current_attempt = 1;
svc->state_type = HARD_STATE;
}

log_debug_info(DEBUGL_CHECKS, 2,
"STATE: %d, TYPE: %s, CUR: %d, MAX: %d, LAST_STATE: %d, LAST_HARD: %d, NOTIFY: %d, LOGGED: %d, HANDLED: %d\n",
svc->current_state,
Expand Down

0 comments on commit a0c8db5

Please sign in to comment.