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

Method StateBeforeSuppressionChangedAPIHandler

lib/icinga/clusterevents.cpp:341–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341Value ClusterEvents::StateBeforeSuppressionChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
342{
343 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
344
345 if (!endpoint) {
346 Log(LogNotice, "ClusterEvents")
347 << "Discarding 'state before suppression changed' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
348 return Empty;
349 }
350
351 Host::Ptr host = Host::GetByName(params->Get("host"));
352
353 if (!host)
354 return Empty;
355
356 Checkable::Ptr checkable;
357
358 if (params->Contains("service"))
359 checkable = host->GetServiceByShortName(params->Get("service"));
360 else
361 checkable = host;
362
363 if (!checkable)
364 return Empty;
365
366 if (origin->FromZone && origin->FromZone != Zone::GetLocalZone()) {
367 Log(LogNotice, "ClusterEvents")
368 << "Discarding 'state before suppression changed' message for checkable '" << checkable->GetName()
369 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
370 return Empty;
371 }
372
373 checkable->SetStateBeforeSuppression(ServiceState(int(params->Get("state_before_suppression"))), false, origin);
374
375 return Empty;
376}
377
378void ClusterEvents::SuppressedNotificationsChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin)
379{

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected