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

Method NextCheckChangedAPIHandler

lib/icinga/clusterevents.cpp:212–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212Value ClusterEvents::NextCheckChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
213{
214 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
215
216 if (!endpoint) {
217 Log(LogNotice, "ClusterEvents")
218 << "Discarding 'next check changed' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
219 return Empty;
220 }
221
222 Host::Ptr host = Host::GetByName(params->Get("host"));
223
224 if (!host)
225 return Empty;
226
227 Checkable::Ptr checkable;
228
229 if (params->Contains("service"))
230 checkable = host->GetServiceByShortName(params->Get("service"));
231 else
232 checkable = host;
233
234 if (!checkable)
235 return Empty;
236
237 if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) {
238 Log(LogNotice, "ClusterEvents")
239 << "Discarding 'next check changed' message for checkable '" << checkable->GetName()
240 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
241 return Empty;
242 }
243
244 double nextCheck = params->Get("next_check");
245
246 if (nextCheck < Application::GetStartTime() + 60)
247 return Empty;
248
249 checkable->SetNextCheck(params->Get("next_check"), false, origin);
250
251 return Empty;
252}
253
254void ClusterEvents::LastCheckStartedChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin)
255{

Callers

nothing calls this directly

Calls 8

LogClass · 0.85
GetEndpointMethod · 0.80
GetIdentityMethod · 0.80
GetServiceByShortNameMethod · 0.80
CanAccessObjectMethod · 0.80
GetMethod · 0.45
ContainsMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected