8000 Mon 13023 recovery notification not sent after downtime by jean-christophe81 · Pull Request #220 · centreon/centreon-collect · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Mon 13023 recovery notification not sent after downtime #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions engine/src/notifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ void notifier::set_last_problem_id(unsigned long last_problem_id) noexcept {
* @param num The notification number.
*/
void notifier::set_notification_number(int num) {
log_v2::notifications()->trace(
"_notification_number set_notification_number: {} => {}",
_notification_number, num);
/* set the notification number */
_notification_number = num;

Expand Down Expand Up @@ -534,6 +537,9 @@ bool notifier::_is_notification_viable_recovery(reason_type type
if (!retval) {
if (!send_later) {
_notification[cat_normal].reset();
log_v2::notifications()->trace(
" _notification_number _is_notification_viable_recovery: {} => 0",
_notification_number);
_notification_number = 0;
}
}
Expand Down Expand Up @@ -916,7 +922,7 @@ int notifier::notify(notifier::reason_type type,
std::string const& not_data,
notification_option options) {
engine_logger(dbg_functions, basic) << "notifier::notify()";
log_v2::functions()->trace("notifier::notify()");
log_v2::functions()->trace("notifier::notify({})", type);
notification_category cat{get_category(type)};

/* Has this notification got sense? */
Expand All @@ -925,8 +931,12 @@ int notifier::notify(notifier::reason_type type,

/* For a first notification, we store what type of notification we try to
* send and we fix the notification number to 1. */
if (type != reason_recovery)
if (type != reason_recovery) {
log_v2::notifications()->trace("_notification_number notify: {} -> {}",
_notification_number,
_notification_number + 1);
++_notification_number;
}

/* What are the contacts to notify? */
uint32_t notification_interval;
Expand Down Expand Up @@ -976,8 +986,11 @@ int notifier::notify(notifier::reason_type type,
}
/* In case of an acknowledgement, we must keep the _notification_number
* otherwise the recovery notification won't be sent when needed. */
if (cat != cat_acknowledgement)
if (cat != cat_acknowledgement && cat != cat_downtime) {
log_v2::notifications()->trace("_notification_number notify: {} => 0",
_notification_number);
_notification_number = 0;
}
}
}

Expand Down
30 changes: 13 additions & 17 deletions engine/src/service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,8 @@ std::string const& service::get_check_command_args() const {
return _check_command_args;
}

static constexpr bool state_changes_use_cached_state = true;

/**
* @brief Handle asynchronously the result of a check.
*
Expand All @@ -1010,8 +1012,6 @@ int service::handle_async_check_result(check_result* queued_check_result) {
std::list<service*> check_servicelist;
com::centreon::engine::service* master_service = nullptr;
int run_async_check = true;
/* TODO - 09/23/07 move this to a global variable */
int state_changes_use_cached_state = true;
int flapping_check_done = false;

engine_logger(dbg_functions, basic) << "handle_async_service_check_result()";
Expand Down Expand Up @@ -1559,9 +1559,8 @@ int service::handle_async_check_result(check_result* queued_check_result) {
set_no_more_notifications(false);

if (reschedule_check)
next_service_check =
(time_t)(get_last_check() +
check_interval() * config->interval_length());
next_service_check = (time_t)(
get_last_check() + check_interval() * config->interval_length());
}

/*******************************************/
Expand Down Expand Up @@ -1740,9 +1739,8 @@ int service::handle_async_check_result(check_result* queued_check_result) {
/* the host is not up, so reschedule the next service check at regular
* interval */
if (reschedule_check)
next_service_check =
(time_t)(get_last_check() +
check_interval() * config->interval_length());
next_service_check = (time_t)(
get_last_check() + check_interval() * config->interval_length());

/* log the problem as a hard state if the host just went down */
if (hard_state_change) {
Expand Down Expand Up @@ -1772,9 +1770,8 @@ int service::handle_async_check_result(check_result* queued_check_result) {
handle_service_event();

if (reschedule_check)
next_service_check =
(time_t)(get_last_check() +
retry_interval() * config->interval_length());
next_service_check = (time_t)(
get_last_check() + retry_interval() * config->interval_length());
}

/* perform dependency checks on the second to last check of the service */
Expand Down Expand Up @@ -1872,9 +1869,8 @@ int service::handle_async_check_result(check_result* queued_check_result) {

/* reschedule the next check at the regular interval */
if (reschedule_check)
next_service_check =
(time_t)(get_last_check() +
check_interval() * config->interval_length());
next_service_check = (time_t)(
get_last_check() + check_interval() * config->interval_length());
}

/* should we obsessive over service checks? */
Expand Down Expand Up @@ -3336,9 +3332,9 @@ bool service::is_result_fresh(time_t current_time, int log_this) {
* suggested by Altinity */
else if (this->active_checks_enabled() && event_start > get_last_check() &&
this->get_freshness_threshold() == 0)
expiration_time = (time_t)(event_start + freshness_threshold +
(config->max_service_check_spread() *
config->interval_length()));
expiration_time = (time_t)(
event_start + freshness_threshold +
(config->max_service_check_spread() * config->interval_length()));
else
expiration_time = (time_t)(get_last_check() + freshness_threshold);

Expand Down
1 change: 1 addition & 0 deletions engine/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ if (WITH_TESTING)
"${TESTS_DIR}/notifications/service_normal_notification.cc"
"${TESTS_DIR}/notifications/service_timeperiod_notification.cc"
"${TESTS_DIR}/notifications/service_flapping_notification.cc"
"${TESTS_DIR}/notifications/service_downtime_notification_test.cc"
"${TESTS_DIR}/perfdata/perfdata.cc"
"${TESTS_DIR}/retention/host.cc"
"${TESTS_DIR}/retention/service.cc"
Expand Down
Loading
0