]> granicus.if.org Git - icinga2/commitdiff
Use UpdateNextCheck() for determining the retry_interval in ProcessCheckResult()
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 15 Mar 2016 12:02:38 +0000 (13:02 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 20 Apr 2016 08:00:08 +0000 (10:00 +0200)
This patch also moves the next check updates for passive
check results into ProcessCheckResult(). That way the
next check status updates for DB IDO work in a sane way
again.

refs #11336

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

index a67121b5328b64fbe20e44ca91bb1c7b2ae22d0a..37f22cc43f1fc5682aa67dccc4035d43b27cd252 100644 (file)
@@ -110,11 +110,6 @@ Dictionary::Ptr ApiActions::ProcessCheckResult(const ConfigObject::Ptr& object,
 
        checkable->ProcessCheckResult(cr);
 
-       /* Reschedule the next check. The side effect of this is that for as long
-        * as we receive passive results for a service we won't execute any
-        * active checks. */
-       checkable->SetNextCheck(Utility::GetTime() + checkable->GetCheckInterval());
-
        return ApiActions::CreateResult(200, "Successfully processed check result for object '" + checkable->GetName() + "'.");
 }
 
index 79c690f06c45eb1175cae0f2632f7dad0f485240..c5f3b605b08ee93998d60fcedfa6714fa8af2196 100644 (file)
@@ -61,7 +61,7 @@ long Checkable::GetSchedulingOffset(void)
        return m_SchedulingOffset;
 }
 
-void Checkable::UpdateNextCheck(void)
+void Checkable::UpdateNextCheck(const MessageOrigin::Ptr& origin)
 {
        double interval;
 
@@ -76,7 +76,7 @@ void Checkable::UpdateNextCheck(void)
        if (interval > 1)
                adj = fmod(now * 100 + GetSchedulingOffset(), interval * 100) / 100.0;
 
-       SetNextCheck(now - adj + interval);
+       SetNextCheck(now - adj + interval, false, origin);
 }
 
 bool Checkable::HasBeenChecked(void) const
@@ -198,13 +198,6 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
                } else if (IsStateOK(old_state)) {
                        SetStateType(StateTypeSoft);
                        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;
                }
@@ -329,6 +322,18 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
 
        is_flapping = IsFlapping();
 
+       if (cr->GetActive()) {
+               /* 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. */
+               UpdateNextCheck(origin);
+       } else {
+               /* Reschedule the next check for passive check results. The side effect of
+                * this is that for as long as we receive passive results for a service we
+                * won't execute any active checks. */
+               SetNextCheck(Utility::GetTime() + GetCheckInterval(), false, origin);
+       }
+
        olock.Unlock();
 
 //     Log(LogDebug, "Checkable")
index 84980642087cd6c1e42dc9f9274e3e741a7c707a..a576f5768e15b097c58c634f92964c941b760ada 100644 (file)
@@ -89,7 +89,7 @@ public:
        long GetSchedulingOffset(void);
        void SetSchedulingOffset(long offset);
 
-       void UpdateNextCheck(void);
+       void UpdateNextCheck(const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
 
        bool HasBeenChecked(void) const;
        virtual bool IsStateOK(ServiceState state) = 0;
index a98127e1e0adc82b604da1b2c5a8956bd13b0f6b..09eeac2a97a417541424118524d178121bc1211a 100644 (file)
@@ -329,11 +329,6 @@ void ExternalCommandProcessor::ProcessHostCheckResult(double time, const std::ve
            << "Processing passive check result for host '" << arguments[0] << "'";
 
        host->ProcessCheckResult(result);
-
-       /* Reschedule the next check. The side effect of this is that for as long
-        * as we receive passive results for a service we won't execute any
-        * active checks. */
-       host->SetNextCheck(Utility::GetTime() + host->GetCheckInterval());
 }
 
 void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std::vector<String>& arguments)
@@ -366,11 +361,6 @@ void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std:
            << "Processing passive check result for service '" << arguments[1] << "'";
 
        service->ProcessCheckResult(result);
-
-       /* Reschedule the next check. The side effect of this is that for as long
-        * as we receive passive results for a service we won't execute any
-        * active checks. */
-       service->SetNextCheck(Utility::GetTime() + service->GetCheckInterval());
 }
 
 void ExternalCommandProcessor::ScheduleHostCheck(double, const std::vector<String>& arguments)