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

Method AcknowledgeHostProblemExpire

lib/icinga/externalcommandprocessor.cpp:708–736  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

706}
707
708void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const std::vector<String>& arguments)
709{
710 bool sticky = (Convert::ToLong(arguments[1]) == 2 ? true : false);
711 bool notify = (Convert::ToLong(arguments[2]) > 0 ? true : false);
712 bool persistent = (Convert::ToLong(arguments[3]) > 0 ? true : false);
713 double timestamp = Convert::ToDouble(arguments[4]);
714
715 Host::Ptr host = Host::GetByName(arguments[0]);
716 ObjectLock oLock (host);
717
718 if (!host)
719 BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge host problem with expire time for non-existent host '" + arguments[0] + "'"));
720
721 Log(LogNotice, "ExternalCommandProcessor")
722 << "Setting timed acknowledgement for host '" << host->GetName() << "'" << (notify ? "" : ". Disabled notification");
723
724 if (host->GetState() == HostUp)
725 BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK."));
726
727 if (timestamp != 0 && timestamp <= Utility::GetTime())
728 BOOST_THROW_EXCEPTION(std::invalid_argument("Acknowledgement expire time must be in the future for host '" + arguments[0] + "'"));
729
730 if (host->IsAcknowledged()) {
731 BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[1] + "' is already acknowledged."));
732 }
733
734 Comment::AddComment(host, CommentAcknowledgement, arguments[5], arguments[6], persistent, timestamp, sticky);
735 host->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal, notify, persistent, Utility::GetTime(), timestamp);
736}
737
738void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const std::vector<String>& arguments)
739{

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