"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/icinga/externalcommandprocessor.cpp" between
icinga2-2.11.5.tar.gz and icinga2-2.12.0.tar.gz

About: Icinga 2 is an enterprise grade monitoring system which keeps watch over networks and any conceivable network resource.

externalcommandprocessor.cpp  (icinga2-2.11.5):externalcommandprocessor.cpp  (icinga2-2.12.0)
skipping to change at line 591 skipping to change at line 591
} }
} }
void ExternalCommandProcessor::AcknowledgeSvcProblem(double, const std::vector<S tring>& arguments) void ExternalCommandProcessor::AcknowledgeSvcProblem(double, const std::vector<S tring>& arguments)
{ {
bool sticky = (Convert::ToLong(arguments[2]) == 2 ? true : false); bool sticky = (Convert::ToLong(arguments[2]) == 2 ? true : false);
bool notify = (Convert::ToLong(arguments[3]) > 0 ? true : false); bool notify = (Convert::ToLong(arguments[3]) > 0 ? true : false);
bool persistent = (Convert::ToLong(arguments[4]) > 0 ? true : false); bool persistent = (Convert::ToLong(arguments[4]) > 0 ? true : false);
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]) ; Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]) ;
ObjectLock oLock (service);
if (!service) if (!service)
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge s ervice problem for non-existent service '" + arguments[1] + "' on host '" + argu ments[0] + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge s ervice problem for non-existent service '" + arguments[1] + "' on host '" + argu ments[0] + "'"));
if (service->GetState() == ServiceOK) if (service->GetState() == ServiceOK)
BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arg uments[1] + "' is OK.")); BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arg uments[1] + "' is OK."));
if (service->IsAcknowledged()) {
BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arg
uments[1] + "' is already acknowledged."));
}
Log(LogNotice, "ExternalCommandProcessor") Log(LogNotice, "ExternalCommandProcessor")
<< "Setting acknowledgement for service '" << service->GetName() << "'" << (notify ? "" : ". Disabled notification"); << "Setting acknowledgement for service '" << service->GetName() << "'" << (notify ? "" : ". Disabled notification");
Comment::AddComment(service, CommentAcknowledgement, arguments[5], argume nts[6], persistent, 0); Comment::AddComment(service, CommentAcknowledgement, arguments[5], argume nts[6], persistent, 0);
service->AcknowledgeProblem(arguments[5], arguments[6], sticky ? Acknowle dgementSticky : AcknowledgementNormal, notify, persistent); service->AcknowledgeProblem(arguments[5], arguments[6], sticky ? Acknowle dgementSticky : AcknowledgementNormal, notify, persistent);
} }
void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const std::ve ctor<String>& arguments) void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const std::ve ctor<String>& arguments)
{ {
bool sticky = (Convert::ToLong(arguments[2]) == 2 ? true : false); bool sticky = (Convert::ToLong(arguments[2]) == 2 ? true : false);
bool notify = (Convert::ToLong(arguments[3]) > 0 ? true : false); bool notify = (Convert::ToLong(arguments[3]) > 0 ? true : false);
bool persistent = (Convert::ToLong(arguments[4]) > 0 ? true : false); bool persistent = (Convert::ToLong(arguments[4]) > 0 ? true : false);
double timestamp = Convert::ToDouble(arguments[5]); double timestamp = Convert::ToDouble(arguments[5]);
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]) ; Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]) ;
ObjectLock oLock (service);
if (!service) if (!service)
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge s ervice problem with expire time for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge s ervice problem with expire time for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
if (service->GetState() == ServiceOK) if (service->GetState() == ServiceOK)
BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arg uments[1] + "' is OK.")); BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arg uments[1] + "' is OK."));
if (timestamp != 0 && timestamp <= Utility::GetTime()) if (timestamp != 0 && timestamp <= Utility::GetTime())
BOOST_THROW_EXCEPTION(std::invalid_argument("Acknowledgement expi re time must be in the future for service '" + arguments[1] + "' on host '" + ar guments[0] + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Acknowledgement expi re time must be in the future for service '" + arguments[1] + "' on host '" + ar guments[0] + "'"));
if (service->IsAcknowledged()) {
BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arg
uments[1] + "' is already acknowledged."));
}
Log(LogNotice, "ExternalCommandProcessor") Log(LogNotice, "ExternalCommandProcessor")
<< "Setting timed acknowledgement for service '" << service->GetN ame() << "'" << (notify ? "" : ". Disabled notification"); << "Setting timed acknowledgement for service '" << service->GetN ame() << "'" << (notify ? "" : ". Disabled notification");
Comment::AddComment(service, CommentAcknowledgement, arguments[6], argume nts[7], persistent, timestamp); Comment::AddComment(service, CommentAcknowledgement, arguments[6], argume nts[7], persistent, timestamp);
service->AcknowledgeProblem(arguments[6], arguments[7], sticky ? Acknowle dgementSticky : AcknowledgementNormal, notify, persistent, timestamp); service->AcknowledgeProblem(arguments[6], arguments[7], sticky ? Acknowle dgementSticky : AcknowledgementNormal, notify, persistent, timestamp);
} }
void ExternalCommandProcessor::RemoveSvcAcknowledgement(double, const std::vecto r<String>& arguments) void ExternalCommandProcessor::RemoveSvcAcknowledgement(double, const std::vecto r<String>& arguments)
{ {
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]) ; Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]) ;
if (!service) if (!service)
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot remove servic e acknowledgement for non-existent service '" + arguments[1] + "' on host '" + a rguments[0] + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot remove servic e acknowledgement for non-existent service '" + arguments[1] + "' on host '" + a rguments[0] + "'"));
Log(LogNotice, "ExternalCommandProcessor") Log(LogNotice, "ExternalCommandProcessor")
<< "Removing acknowledgement for service '" << service->GetName() << "'"; << "Removing acknowledgement for service '" << service->GetName() << "'";
{ {
ObjectLock olock(service); ObjectLock olock(service);
service->ClearAcknowledgement(); service->ClearAcknowledgement("");
} }
service->RemoveCommentsByType(CommentAcknowledgement); service->RemoveCommentsByType(CommentAcknowledgement);
} }
void ExternalCommandProcessor::AcknowledgeHostProblem(double, const std::vector< String>& arguments) void ExternalCommandProcessor::AcknowledgeHostProblem(double, const std::vector< String>& arguments)
{ {
bool sticky = (Convert::ToLong(arguments[1]) == 2 ? true : false); bool sticky = (Convert::ToLong(arguments[1]) == 2 ? true : false);
bool notify = (Convert::ToLong(arguments[2]) > 0 ? true : false); bool notify = (Convert::ToLong(arguments[2]) > 0 ? true : false);
bool persistent = (Convert::ToLong(arguments[3]) > 0 ? true : false); bool persistent = (Convert::ToLong(arguments[3]) > 0 ? true : false);
Host::Ptr host = Host::GetByName(arguments[0]); Host::Ptr host = Host::GetByName(arguments[0]);
ObjectLock oLock (host);
if (!host) if (!host)
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge h ost problem for non-existent host '" + arguments[0] + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge h ost problem for non-existent host '" + arguments[0] + "'"));
Log(LogNotice, "ExternalCommandProcessor") Log(LogNotice, "ExternalCommandProcessor")
<< "Setting acknowledgement for host '" << host->GetName() << "'" << (notify ? "" : ". Disabled notification"); << "Setting acknowledgement for host '" << host->GetName() << "'" << (notify ? "" : ". Disabled notification");
if (host->GetState() == HostUp) if (host->GetState() == HostUp)
BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + argume nts[0] + "' is OK.")); BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + argume nts[0] + "' is OK."));
if (host->IsAcknowledged()) {
BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + argume
nts[1] + "' is already acknowledged."));
}
Comment::AddComment(host, CommentAcknowledgement, arguments[4], arguments [5], persistent, 0); Comment::AddComment(host, CommentAcknowledgement, arguments[4], arguments [5], persistent, 0);
host->AcknowledgeProblem(arguments[4], arguments[5], sticky ? Acknowledge mentSticky : AcknowledgementNormal, notify, persistent); host->AcknowledgeProblem(arguments[4], arguments[5], sticky ? Acknowledge mentSticky : AcknowledgementNormal, notify, persistent);
} }
void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const std::v ector<String>& arguments) void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const std::v ector<String>& arguments)
{ {
bool sticky = (Convert::ToLong(arguments[1]) == 2 ? true : false); bool sticky = (Convert::ToLong(arguments[1]) == 2 ? true : false);
bool notify = (Convert::ToLong(arguments[2]) > 0 ? true : false); bool notify = (Convert::ToLong(arguments[2]) > 0 ? true : false);
bool persistent = (Convert::ToLong(arguments[3]) > 0 ? true : false); bool persistent = (Convert::ToLong(arguments[3]) > 0 ? true : false);
double timestamp = Convert::ToDouble(arguments[4]); double timestamp = Convert::ToDouble(arguments[4]);
Host::Ptr host = Host::GetByName(arguments[0]); Host::Ptr host = Host::GetByName(arguments[0]);
ObjectLock oLock (host);
if (!host) if (!host)
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge h ost problem with expire time for non-existent host '" + arguments[0] + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge h ost problem with expire time for non-existent host '" + arguments[0] + "'"));
Log(LogNotice, "ExternalCommandProcessor") Log(LogNotice, "ExternalCommandProcessor")
<< "Setting timed acknowledgement for host '" << host->GetName() << "'" << (notify ? "" : ". Disabled notification"); << "Setting timed acknowledgement for host '" << host->GetName() << "'" << (notify ? "" : ". Disabled notification");
if (host->GetState() == HostUp) if (host->GetState() == HostUp)
BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + argume nts[0] + "' is OK.")); BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + argume nts[0] + "' is OK."));
if (timestamp != 0 && timestamp <= Utility::GetTime()) if (timestamp != 0 && timestamp <= Utility::GetTime())
BOOST_THROW_EXCEPTION(std::invalid_argument("Acknowledgement expi re time must be in the future for host '" + arguments[0] + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Acknowledgement expi re time must be in the future for host '" + arguments[0] + "'"));
if (host->IsAcknowledged()) {
BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + argume
nts[1] + "' is already acknowledged."));
}
Comment::AddComment(host, CommentAcknowledgement, arguments[5], arguments [6], persistent, timestamp); Comment::AddComment(host, CommentAcknowledgement, arguments[5], arguments [6], persistent, timestamp);
host->AcknowledgeProblem(arguments[5], arguments[6], sticky ? Acknowledge mentSticky : AcknowledgementNormal, notify, persistent, timestamp); host->AcknowledgeProblem(arguments[5], arguments[6], sticky ? Acknowledge mentSticky : AcknowledgementNormal, notify, persistent, timestamp);
} }
void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const std::vect or<String>& arguments) void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const std::vect or<String>& arguments)
{ {
Host::Ptr host = Host::GetByName(arguments[0]); Host::Ptr host = Host::GetByName(arguments[0]);
if (!host) if (!host)
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot remove acknow ledgement for non-existent host '" + arguments[0] + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot remove acknow ledgement for non-existent host '" + arguments[0] + "'"));
Log(LogNotice, "ExternalCommandProcessor") Log(LogNotice, "ExternalCommandProcessor")
<< "Removing acknowledgement for host '" << host->GetName() << "' "; << "Removing acknowledgement for host '" << host->GetName() << "' ";
{ {
ObjectLock olock(host); ObjectLock olock(host);
host->ClearAcknowledgement(); host->ClearAcknowledgement("");
} }
host->RemoveCommentsByType(CommentAcknowledgement); host->RemoveCommentsByType(CommentAcknowledgement);
} }
void ExternalCommandProcessor::EnableHostgroupSvcChecks(double, const std::vecto r<String>& arguments) void ExternalCommandProcessor::EnableHostgroupSvcChecks(double, const std::vecto r<String>& arguments)
{ {
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]); HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
if (!hg) if (!hg)
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgr oup service checks for non-existent hostgroup '" + arguments[0] + "'")); BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgr oup service checks for non-existent hostgroup '" + arguments[0] + "'"));
 End of changes. 10 change blocks. 
2 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)