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

Method ExecuteCheck

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

Source from the content-addressed store, hash-verified

559}
560
561void Checkable::ExecuteCheck(const WaitGroup::Ptr& producer)
562{
563 CONTEXT("Executing check for object '" << GetName() << "'");
564
565 /* keep track of scheduling info in case the check type doesn't provide its own information */
566 double scheduled_start = GetNextCheck();
567 double before_check = Utility::GetTime();
568
569 SetLastCheckStarted(Utility::GetTime());
570
571 /* This calls SetNextCheck() which updates the CheckerComponent's idle/pending
572 * queues and ensures that checks are not fired multiple times. ProcessCheckResult()
573 * is called too late. See #6421.
574 */
575 UpdateNextCheck();
576
577 bool reachable = IsReachable();
578
579 {
580 ObjectLock olock(this);
581
582 /* don't run another check if there is one pending */
583 if (m_CheckRunning)
584 return;
585
586 m_CheckRunning = true;
587
588 SetLastStateRaw(GetStateRaw());
589 SetLastStateType(GetLastStateType());
590 SetLastReachable(reachable);
591 }
592
593 CheckResult::Ptr cr = new CheckResult();
594
595 cr->SetScheduleStart(scheduled_start);
596 cr->SetExecutionStart(before_check);
597
598 Endpoint::Ptr endpoint = GetCommandEndpoint();
599 bool local = !endpoint || endpoint == Endpoint::GetLocalEndpoint();
600
601 if (local) {
602 GetCheckCommand()->Execute(this, cr, producer, nullptr, false);
603 } else {
604 Dictionary::Ptr macros = new Dictionary();
605 GetCheckCommand()->Execute(this, cr, producer, macros, false);
606
607 if (endpoint->GetConnected()) {
608 /* perform check on remote endpoint */
609 Dictionary::Ptr message = new Dictionary();
610 message->Set("jsonrpc", "2.0");
611 message->Set("method", "event::ExecuteCommand");
612
613 Host::Ptr host;
614 Service::Ptr service;
615 tie(host, service) = GetHostService(this);
616
617 Dictionary::Ptr params = new Dictionary();
618 message->Set("params", params);

Callers 1

ExecuteCheckHelperMethod · 0.80

Calls 8

GetConnectedMethod · 0.80
GetTimeoutMethod · 0.80
SyncSendMessageMethod · 0.80
GetStartTimeMethod · 0.80
ExecuteMethod · 0.45
SetMethod · 0.45
GetNameMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected