Implement CHANGE_HOST_MODATTR.

This commit is contained in:
Gunnar Beutner 2013-10-16 12:08:36 +02:00
parent 53ca2d3916
commit d07dc47b1b
2 changed files with 24 additions and 0 deletions

View File

@ -181,6 +181,7 @@ void ExternalCommandProcessor::Initialize(void)
RegisterCommand("START_EXECUTING_SVC_CHECKS", &ExternalCommandProcessor::StartExecutingSvcChecks);
RegisterCommand("STOP_EXECUTING_SVC_CHECKS", &ExternalCommandProcessor::StopExecutingSvcChecks);
RegisterCommand("CHANGE_SVC_MODATTR", &ExternalCommandProcessor::ChangeSvcModAttr);
RegisterCommand("CHANGE_HOST_MODATTR", &ExternalCommandProcessor::ChangeHostModAttr);
}
void ExternalCommandProcessor::RegisterCommand(const String& command, const ExternalCommandProcessor::Callback& callback)
@ -1836,4 +1837,26 @@ void ExternalCommandProcessor::ChangeSvcModAttr(double time, const std::vector<S
service->SetModifiedAttributes(modifiedAttributes);
}
}
void ExternalCommandProcessor::ChangeHostModAttr(double time, const std::vector<String>& arguments)
{
if (arguments.size() < 3)
BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 3 arguments."));
Host::Ptr host = Host::GetByName(arguments[0]);
if (!host)
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update modified attributes for non-existent host '" + arguments[0] + "'"));
Log(LogInformation, "icinga", "Updating modified attributes for for host '" + arguments[0] + "'");
Service::Ptr hc = host->GetCheckService();
int modifiedAttributes = Convert::ToLong(arguments[2]);
{
ObjectLock olock(service);
hc->SetModifiedAttributes(modifiedAttributes);
}
}

View File

@ -132,6 +132,7 @@ private:
static void StartExecutingSvcChecks(double time, const std::vector<String>& arguments);
static void StopExecutingSvcChecks(double time, const std::vector<String>& arguments);
static void ChangeSvcModAttr(double time, const std::vector<String>& arguments);
static void ChangeHostModAttr(double time, const std::vector<String>& arguments);
};
}