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

Method LastCheckStartedChangedAPIHandler

lib/icinga/clusterevents.cpp:279–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277}
278
279Value ClusterEvents::LastCheckStartedChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
280{
281 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
282
283 if (!endpoint) {
284 Log(LogNotice, "ClusterEvents")
285 << "Discarding 'last_check_started changed' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
286 return Empty;
287 }
288
289 Host::Ptr host = Host::GetByName(params->Get("host"));
290
291 if (!host)
292 return Empty;
293
294 Checkable::Ptr checkable;
295
296 if (params->Contains("service"))
297 checkable = host->GetServiceByShortName(params->Get("service"));
298 else
299 checkable = host;
300
301 if (!checkable)
302 return Empty;
303
304 if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) {
305 Log(LogNotice, "ClusterEvents")
306 << "Discarding 'last_check_started changed' message for checkable '" << checkable->GetName()
307 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
308 return Empty;
309 }
310
311 checkable->SetLastCheckStarted(params->Get("last_check_started"), false, origin);
312
313 return Empty;
314}
315
316void ClusterEvents::StateBeforeSuppressionChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin)
317{

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