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

Method ChangeSvcEventHandler

lib/icinga/externalcommandprocessor.cpp:1976–1999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1974}
1975
1976void ExternalCommandProcessor::ChangeSvcEventHandler(double, const std::vector<String>& arguments)
1977{
1978 Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
1979
1980 if (!service)
1981 BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change event handler for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
1982
1983 if (arguments[2].IsEmpty()) {
1984 Log(LogNotice, "ExternalCommandProcessor")
1985 << "Unsetting event handler for service '" << arguments[1] << "'";
1986
1987 service->ModifyAttribute("event_command", "");
1988 } else {
1989 EventCommand::Ptr command = EventCommand::GetByName(arguments[2]);
1990
1991 if (!command)
1992 BOOST_THROW_EXCEPTION(std::invalid_argument("Event command '" + arguments[2] + "' does not exist."));
1993
1994 Log(LogNotice, "ExternalCommandProcessor")
1995 << "Changing event handler for service '" << arguments[1] << "' to '" << arguments[2] << "'";
1996
1997 service->ModifyAttribute("event_command", command->GetName());
1998 }
1999}
2000
2001void ExternalCommandProcessor::ChangeHostCheckCommand(double, const std::vector<String>& arguments)
2002{

Callers

nothing calls this directly

Calls 4

LogClass · 0.85
ModifyAttributeMethod · 0.80
IsEmptyMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected