]> granicus.if.org Git - icinga2/commitdiff
Use retry_interval on first OK -> NOT-OK state change
authorMichael Friedrich <michael.friedrich@netways.de>
Fri, 11 Mar 2016 09:30:50 +0000 (10:30 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 20 Apr 2016 08:00:07 +0000 (10:00 +0200)
Only valid for active check results. The API actions were
missing that marker similar to the external command processor.

The initial OK -> NOT-OK transition should use the retry_interval
but nothing else.

fixes #11336

lib/icinga/apiactions.cpp
lib/icinga/checkable-check.cpp
lib/icinga/externalcommandprocessor.cpp

index 9faa0304c123dfb9fd567f3207d15b43aac7fbbb..a67121b5328b64fbe20e44ca91bb1c7b2ae22d0a 100644 (file)
@@ -104,6 +104,10 @@ Dictionary::Ptr ApiActions::ProcessCheckResult(const ConfigObject::Ptr& object,
        cr->SetCheckSource(HttpUtility::GetLastParameter(params, "check_source"));
        cr->SetPerformanceData(params->Get("performance_data"));
        cr->SetCommand(params->Get("check_command"));
+
+       /* Mark this check result as passive. */
+       cr->SetActive(false);
+
        checkable->ProcessCheckResult(cr);
 
        /* Reschedule the next check. The side effect of this is that for as long
index 42dd993f508a3fa41dade96320364dd691425df2..79c690f06c45eb1175cae0f2632f7dad0f485240 100644 (file)
@@ -197,7 +197,14 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
                        attempt = old_attempt + 1; // NOT-OK -> NOT-OK counter
                } else if (IsStateOK(old_state)) {
                        SetStateType(StateTypeSoft);
-                       attempt = 1; //OK -> NOT-OK transition, reset the counter
+                       attempt = 1; // OK -> NOT-OK transition, reset the counter
+
+                       /* If there was a OK -> NOT-OK state change for actively scheduled checks,
+                        * update the next check time using the retry_interval.
+                        * Important: Add the cluster message origin.
+                        */
+                       if (cr->GetActive())
+                               SetNextCheck(Utility::GetTime() + GetRetryInterval(), false, origin);
                } else {
                        attempt = old_attempt;
                }
index f0889376cbc500b3b3868ba65495329a7bb37971..a98127e1e0adc82b604da1b2c5a8956bd13b0f6b 100644 (file)
@@ -321,6 +321,8 @@ void ExternalCommandProcessor::ProcessHostCheckResult(double time, const std::ve
        result->SetScheduleEnd(time);
        result->SetExecutionStart(time);
        result->SetExecutionEnd(time);
+
+       /* Mark this check result as passive. */
        result->SetActive(false);
 
        Log(LogNotice, "ExternalCommandProcessor")
@@ -356,6 +358,8 @@ void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std:
        result->SetScheduleEnd(time);
        result->SetExecutionStart(time);
        result->SetExecutionEnd(time);
+
+       /* Mark this check result as passive. */
        result->SetActive(false);
 
        Log(LogNotice, "ExternalCommandProcessor")