MCPcopy Create free account
hub / github.com/Icinga/icinga2 / UpdateNextCheck

Method UpdateNextCheck

lib/icinga/checkable-check.cpp:54–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54void Checkable::UpdateNextCheck(const MessageOrigin::Ptr& origin)
55{
56 double interval;
57
58 if (GetStateType() == StateTypeSoft && GetLastCheckResult() != nullptr)
59 interval = GetRetryInterval();
60 else
61 interval = GetCheckInterval();
62
63 double now = Utility::GetTime();
64 double adj = 0;
65
66 if (interval > 1)
67 adj = fmod(now * 100 + GetSchedulingOffset(), interval * 100) / 100.0;
68
69 if (adj != 0.0)
70 adj = std::min(0.5 + fmod(GetSchedulingOffset(), interval * 5) / 100.0, adj);
71
72 double nextCheck = now - adj + interval;
73 double lastCheck = GetLastCheck();
74
75 Log(LogDebug, "Checkable")
76 << std::fixed << std::setprecision(0)
77 << "Update checkable '" << GetName() << "' with check interval '" << GetCheckInterval()
78 << "' from last check time at " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", (lastCheck < 0 ? 0 : lastCheck))
79 << " (" << lastCheck << ") to next check time at "
80 << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", nextCheck) << " (" << nextCheck << ").";
81
82 SetNextCheck(nextCheck, false, origin);
83}
84
85bool Checkable::HasBeenChecked() const
86{

Callers 1

CheckThreadProcMethod · 0.80

Calls 1

LogClass · 0.85

Tested by

no test coverage detected