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

Method IsAvailable

lib/icinga/dependency.cpp:295–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295bool Dependency::IsAvailable(DependencyType dt) const
296{
297 Checkable::Ptr parent = GetParent();
298
299 Host::Ptr parentHost;
300 Service::Ptr parentService;
301 tie(parentHost, parentService) = GetHostService(parent);
302
303 /* ignore if it's the same checkable object */
304 if (parent == GetChild()) {
305 Log(LogNotice, "Dependency")
306 << "Dependency '" << GetName() << "' passed: Parent and child " << (parentService ? "service" : "host") << " are identical.";
307 return true;
308 }
309
310 /* ignore pending */
311 if (!parent->GetLastCheckResult()) {
312 Log(LogNotice, "Dependency")
313 << "Dependency '" << GetName() << "' passed: Parent " << (parentService ? "service" : "host") << " '" << parent->GetName() << "' hasn't been checked yet.";
314 return true;
315 }
316
317 if (GetIgnoreSoftStates()) {
318 /* ignore soft states */
319 if (parent->GetStateType() == StateTypeSoft) {
320 Log(LogNotice, "Dependency")
321 << "Dependency '" << GetName() << "' passed: Parent " << (parentService ? "service" : "host") << " '" << parent->GetName() << "' is in a soft state.";
322 return true;
323 }
324 } else {
325 Log(LogNotice, "Dependency")
326 << "Dependency '" << GetName() << "' failed: Parent " << (parentService ? "service" : "host") << " '" << parent->GetName() << "' is in a soft state.";
327 }
328
329 int state;
330
331 if (parentService)
332 state = ServiceStateToFilter(parentService->GetState());
333 else
334 state = HostStateToFilter(parentHost->GetState());
335
336 /* check state */
337 if (state & GetStateFilter()) {
338 Log(LogNotice, "Dependency")
339 << "Dependency '" << GetName() << "' passed: Parent " << (parentService ? "service" : "host") << " '" << parent->GetName() << "' matches state filter.";
340 return true;
341 }
342
343 /* ignore if not in time period */
344 TimePeriod::Ptr tp = GetPeriod();
345 if (tp && !tp->IsInside(Utility::GetTime())) {
346 Log(LogNotice, "Dependency")
347 << "Dependency '" << GetName() << "' passed: Outside time period.";
348 return true;
349 }
350
351 if (dt == DependencyCheckExecution && !GetDisableChecks()) {
352 Log(LogNotice, "Dependency")

Callers 3

GetStateMethod · 0.80
AffectsChildrenMethod · 0.80

Calls 4

LogClass · 0.85
IsInsideMethod · 0.80
GetNameMethod · 0.45
GetStateMethod · 0.45

Tested by

no test coverage detected