| 99 | } |
| 100 | |
| 101 | Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const WaitGroup::Ptr& producer, const MessageOrigin::Ptr& origin) |
| 102 | { |
| 103 | using Result = Checkable::ProcessingResult; |
| 104 | |
| 105 | VERIFY(cr); |
| 106 | VERIFY(producer); |
| 107 | |
| 108 | ObjectLock olock(this); |
| 109 | m_CheckRunning = false; |
| 110 | |
| 111 | double now = Utility::GetTime(); |
| 112 | |
| 113 | if (cr->GetScheduleStart() == 0) |
| 114 | cr->SetScheduleStart(now); |
| 115 | |
| 116 | if (cr->GetScheduleEnd() == 0) |
| 117 | cr->SetScheduleEnd(now); |
| 118 | |
| 119 | if (cr->GetExecutionStart() == 0) |
| 120 | cr->SetExecutionStart(now); |
| 121 | |
| 122 | if (cr->GetExecutionEnd() == 0) |
| 123 | cr->SetExecutionEnd(now); |
| 124 | |
| 125 | if (!origin || origin->IsLocal()) |
| 126 | cr->SetSchedulingSource(IcingaApplication::GetInstance()->GetNodeName()); |
| 127 | |
| 128 | Endpoint::Ptr command_endpoint = GetCommandEndpoint(); |
| 129 | |
| 130 | if (cr->GetCheckSource().IsEmpty()) { |
| 131 | if ((!origin || origin->IsLocal())) |
| 132 | cr->SetCheckSource(IcingaApplication::GetInstance()->GetNodeName()); |
| 133 | |
| 134 | /* override check source if command_endpoint was defined */ |
| 135 | if (command_endpoint && !GetExtension("agent_check")) |
| 136 | cr->SetCheckSource(command_endpoint->GetName()); |
| 137 | } |
| 138 | |
| 139 | std::shared_lock producerLock (*producer, std::try_to_lock); |
| 140 | |
| 141 | if (!producerLock) { |
| 142 | // Discard the check result to not delay the current reload. |
| 143 | // We'll re-run the check immediately after the reload. |
| 144 | return Result::CheckableInactive; |
| 145 | } |
| 146 | |
| 147 | /* agent checks go through the api */ |
| 148 | if (command_endpoint && GetExtension("agent_check")) { |
| 149 | ApiListener::Ptr listener = ApiListener::GetInstance(); |
| 150 | |
| 151 | if (listener) { |
| 152 | /* send message back to its origin */ |
| 153 | Dictionary::Ptr message = ClusterEvents::MakeCheckResultMessage(this, cr); |
| 154 | listener->SyncSendMessage(command_endpoint, message); |
| 155 | } |
| 156 | |
| 157 | return Result::Ok; |
| 158 |
nothing calls this directly
no test coverage detected