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

Method ForceNextCheckChangedAPIHandler

lib/icinga/clusterevents.cpp:671–706  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

669}
670
671Value ClusterEvents::ForceNextCheckChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
672{
673 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
674
675 if (!endpoint) {
676 Log(LogNotice, "ClusterEvents")
677 << "Discarding 'force next check changed' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
678 return Empty;
679 }
680
681 Host::Ptr host = Host::GetByName(params->Get("host"));
682
683 if (!host)
684 return Empty;
685
686 Checkable::Ptr checkable;
687
688 if (params->Contains("service"))
689 checkable = host->GetServiceByShortName(params->Get("service"));
690 else
691 checkable = host;
692
693 if (!checkable)
694 return Empty;
695
696 if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) {
697 Log(LogNotice, "ClusterEvents")
698 << "Discarding 'force next check' message for checkable '" << checkable->GetName()
699 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
700 return Empty;
701 }
702
703 checkable->SetForceNextCheck(params->Get("forced"), false, origin);
704
705 return Empty;
706}
707
708void ClusterEvents::ForceNextNotificationChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin)
709{

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