mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Empty command string on CHANGE_{HOST,SERVICE}_EVENTHANDLER should disable event handlers.
Fixes #5670
This commit is contained in:
parent
1408c26e5c
commit
ac35eadc8d
@ -2123,17 +2123,22 @@ void ExternalCommandProcessor::ChangeHostEventHandler(double time, const std::ve
|
|||||||
if (!hc)
|
if (!hc)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change event handler for host '" + arguments[0] + "' which has no check service."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change event handler for host '" + arguments[0] + "' which has no check service."));
|
||||||
|
|
||||||
EventCommand::Ptr command = EventCommand::GetByName(arguments[1]);
|
/* empty command string implicitely disables event handler */
|
||||||
|
if (arguments[1].IsEmpty()) {
|
||||||
|
hc->SetEnableEventHandler(false);
|
||||||
|
} else {
|
||||||
|
EventCommand::Ptr command = EventCommand::GetByName(arguments[1]);
|
||||||
|
|
||||||
if (!command)
|
if (!command)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Event command '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Event command '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
Log(LogInformation, "icinga", "Changing event handler for host '" + arguments[0] + "' to '" + arguments[1] + "'");
|
Log(LogInformation, "icinga", "Changing event handler for host '" + arguments[0] + "' to '" + arguments[1] + "'");
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock olock(hc);
|
ObjectLock olock(hc);
|
||||||
|
|
||||||
hc->SetEventCommand(command);
|
hc->SetEventCommand(command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2147,17 +2152,22 @@ void ExternalCommandProcessor::ChangeSvcEventHandler(double time, const std::vec
|
|||||||
if (!service)
|
if (!service)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change event handler for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change event handler for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
|
||||||
|
|
||||||
EventCommand::Ptr command = EventCommand::GetByName(arguments[2]);
|
/* empty command string implicitely disables event handler */
|
||||||
|
if (arguments[2].IsEmpty()) {
|
||||||
|
service->SetEnableEventHandler(false);
|
||||||
|
} else {
|
||||||
|
EventCommand::Ptr command = EventCommand::GetByName(arguments[2]);
|
||||||
|
|
||||||
if (!command)
|
if (!command)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Event command '" + arguments[2] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Event command '" + arguments[2] + "' does not exist."));
|
||||||
|
|
||||||
Log(LogInformation, "icinga", "Changing event handler for service '" + arguments[1] + "' to '" + arguments[2] + "'");
|
Log(LogInformation, "icinga", "Changing event handler for service '" + arguments[1] + "' to '" + arguments[2] + "'");
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock olock(service);
|
ObjectLock olock(service);
|
||||||
|
|
||||||
service->SetEventCommand(command);
|
service->SetEventCommand(command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user