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

Method ChangeHostEventHandler

lib/icinga/externalcommandprocessor.cpp:1951–1974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1949}
1950
1951void ExternalCommandProcessor::ChangeHostEventHandler(double, const std::vector<String>& arguments)
1952{
1953 Host::Ptr host = Host::GetByName(arguments[0]);
1954
1955 if (!host)
1956 BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change event handler for non-existent host '" + arguments[0] + "'"));
1957
1958 if (arguments[1].IsEmpty()) {
1959 Log(LogNotice, "ExternalCommandProcessor")
1960 << "Unsetting event handler for host '" << arguments[0] << "'";
1961
1962 host->ModifyAttribute("event_command", "");
1963 } else {
1964 EventCommand::Ptr command = EventCommand::GetByName(arguments[1]);
1965
1966 if (!command)
1967 BOOST_THROW_EXCEPTION(std::invalid_argument("Event command '" + arguments[1] + "' does not exist."));
1968
1969 Log(LogNotice, "ExternalCommandProcessor")
1970 << "Changing event handler for host '" << arguments[0] << "' to '" << arguments[1] << "'";
1971
1972 host->ModifyAttribute("event_command", command->GetName());
1973 }
1974}
1975
1976void ExternalCommandProcessor::ChangeSvcEventHandler(double, const std::vector<String>& arguments)
1977{

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