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

Method ProcessCheckResult

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

Source from the content-addressed store, hash-verified

99}
100
101Checkable::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

Callers

nothing calls this directly

Calls 13

LogClass · 0.85
IsLocalMethod · 0.80
GetNodeNameMethod · 0.80
SyncSendMessageMethod · 0.80
GetProblemMethod · 0.80
StringClass · 0.50
IsEmptyMethod · 0.45
GetNameMethod · 0.45
GetStateMethod · 0.45
GetServicesMethod · 0.45
emptyMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected