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

Method AcknowledgeHostProblem

lib/icinga/externalcommandprocessor.cpp:682–706  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680}
681
682void ExternalCommandProcessor::AcknowledgeHostProblem(double, const std::vector<String>& arguments)
683{
684 bool sticky = (Convert::ToLong(arguments[1]) == 2 ? true : false);
685 bool notify = (Convert::ToLong(arguments[2]) > 0 ? true : false);
686 bool persistent = (Convert::ToLong(arguments[3]) > 0 ? true : false);
687
688 Host::Ptr host = Host::GetByName(arguments[0]);
689 ObjectLock oLock (host);
690
691 if (!host)
692 BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge host problem for non-existent host '" + arguments[0] + "'"));
693
694 Log(LogNotice, "ExternalCommandProcessor")
695 << "Setting acknowledgement for host '" << host->GetName() << "'" << (notify ? "" : ". Disabled notification");
696
697 if (host->GetState() == HostUp)
698 BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK."));
699
700 if (host->IsAcknowledged()) {
701 BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[1] + "' is already acknowledged."));
702 }
703
704 Comment::AddComment(host, CommentAcknowledgement, arguments[4], arguments[5], persistent, 0, sticky);
705 host->AcknowledgeProblem(arguments[4], arguments[5], sticky ? AcknowledgementSticky : AcknowledgementNormal, notify, persistent);
706}
707
708void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const std::vector<String>& arguments)
709{

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected