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

Method AcknowledgeSvcProblem

lib/icinga/externalcommandprocessor.cpp:608–632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606}
607
608void ExternalCommandProcessor::AcknowledgeSvcProblem(double, const std::vector<String>& arguments)
609{
610 bool sticky = (Convert::ToLong(arguments[2]) == 2 ? true : false);
611 bool notify = (Convert::ToLong(arguments[3]) > 0 ? true : false);
612 bool persistent = (Convert::ToLong(arguments[4]) > 0 ? true : false);
613
614 Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
615 ObjectLock oLock (service);
616
617 if (!service)
618 BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge service problem for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
619
620 if (service->GetState() == ServiceOK)
621 BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arguments[1] + "' is OK."));
622
623 if (service->IsAcknowledged()) {
624 BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arguments[1] + "' is already acknowledged."));
625 }
626
627 Log(LogNotice, "ExternalCommandProcessor")
628 << "Setting acknowledgement for service '" << service->GetName() << "'" << (notify ? "" : ". Disabled notification");
629
630 Comment::AddComment(service, CommentAcknowledgement, arguments[5], arguments[6], persistent, 0, sticky);
631 service->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal, notify, persistent);
632}
633
634void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const std::vector<String>& arguments)
635{

Callers

nothing calls this directly

Calls 5

LogClass · 0.85
IsAcknowledgedMethod · 0.80
GetStateMethod · 0.45
GetNameMethod · 0.45
AcknowledgeProblemMethod · 0.45

Tested by

no test coverage detected