diff --git a/lib/icinga/externalcommandprocessor.cpp b/lib/icinga/externalcommandprocessor.cpp index 4c5b84f5c..4f34728d7 100644 --- a/lib/icinga/externalcommandprocessor.cpp +++ b/lib/icinga/externalcommandprocessor.cpp @@ -219,8 +219,8 @@ void ExternalCommandProcessor::ProcessHostCheckResult(double time, const std::ve Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot process passive host check result for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot process passive host check result for host '" + arguments[0] + "' which has no check service.")); if (!hc->GetEnablePassiveChecks()) BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for host '" + arguments[0] + "' which has passive checks disabled.")); @@ -296,8 +296,8 @@ void ExternalCommandProcessor::ScheduleHostCheck(double, const std::vectorGetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule host check for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule host check for host '" + arguments[0] + "' which has no check service.")); double planned_check = Convert::ToDouble(arguments[1]); @@ -331,8 +331,8 @@ void ExternalCommandProcessor::ScheduleForcedHostCheck(double, const std::vector Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule forced host check for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule forced host check for host '" + arguments[0] + "' which has no check service.")); Log(LogInformation, "icinga", "Rescheduling next check for host '" + arguments[0] + "'"); @@ -406,10 +406,10 @@ void ExternalCommandProcessor::EnableHostCheck(double, const std::vector Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host checks for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host checks for host '" + arguments[0] + "' which has no check service.")); - Log(LogInformation, "icinga", "Enabling active checks for host '" + arguments[0] + "'"); + Log(LogInformation, "icinga", "Enabling active checks for host '" + arguments[0] + "'"); { ObjectLock olock(hc); @@ -430,10 +430,10 @@ void ExternalCommandProcessor::DisableHostCheck(double, const std::vectorGetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host checks for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host checks for host '" + arguments[0] + "' which has no check service.")); - Log(LogInformation, "icinga", "Disabling active checks for host '" + arguments[0] + "'"); + Log(LogInformation, "icinga", "Disabling active checks for host '" + arguments[0] + "'"); { ObjectLock olock(hc); @@ -807,10 +807,10 @@ void ExternalCommandProcessor::EnablePassiveHostChecks(double, const std::vector Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable passive host checks for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable passive host checks for host '" + arguments[0] + "' which has no check service.")); - Log(LogInformation, "icinga", "Enabling passive checks for host '" + arguments[0] + "'"); + Log(LogInformation, "icinga", "Enabling passive checks for host '" + arguments[0] + "'"); { ObjectLock olock(hc); @@ -831,10 +831,10 @@ void ExternalCommandProcessor::DisablePassiveHostChecks(double, const std::vecto Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable passive host checks for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable passive host checks for host '" + arguments[0] + "' which has no check service.")); - Log(LogInformation, "icinga", "Disabling passive checks for host '" + arguments[0] + "'"); + Log(LogInformation, "icinga", "Disabling passive checks for host '" + arguments[0] + "'"); { ObjectLock olock(hc); @@ -1354,10 +1354,10 @@ void ExternalCommandProcessor::DelayHostNotification(double, const std::vectorGetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot delay host notification for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot delay host notification for host '" + arguments[0] + "' which has no check service.")); - Log(LogInformation, "icinga", "Delaying notifications for host '" + host->GetName() + "'"); + Log(LogInformation, "icinga", "Delaying notifications for host '" + host->GetName() + "'"); BOOST_FOREACH(const Notification::Ptr& notification, hc->GetNotifications()) { ObjectLock olock(notification); @@ -1397,10 +1397,10 @@ void ExternalCommandProcessor::EnableHostNotifications(double, const std::vector Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host notifications for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host notifications for host '" + arguments[0] + "' which has no check service.")); - Log(LogInformation, "icinga", "Enabling notifications for host '" + arguments[0] + "'"); + Log(LogInformation, "icinga", "Enabling notifications for host '" + arguments[0] + "'"); { ObjectLock olock(hc); @@ -1421,10 +1421,10 @@ void ExternalCommandProcessor::DisableHostNotifications(double, const std::vecto Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host notifications for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host notifications for host '" + arguments[0] + "' which has no check service.")); - Log(LogInformation, "icinga", "Disabling notifications for host '" + arguments[0] + "'"); + Log(LogInformation, "icinga", "Disabling notifications for host '" + arguments[0] + "'"); { ObjectLock olock(hc); @@ -1484,17 +1484,17 @@ void ExternalCommandProcessor::DisableHostgroupHostChecks(double, const std::vec BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { Service::Ptr hc = host->GetCheckService(); - if (!hc) { - Log(LogInformation, "icinga", "Cannot disable active checks for host '" + host->GetName() + "' which has no check service."); - } else { - Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'"); + if (!hc) { + Log(LogInformation, "icinga", "Cannot disable active checks for host '" + host->GetName() + "' which has no check service."); + } else { + Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'"); - { - ObjectLock olock(hc); + { + ObjectLock olock(hc); - hc->SetEnableActiveChecks(false); - } - } + hc->SetEnableActiveChecks(false); + } + } } } @@ -1511,17 +1511,17 @@ void ExternalCommandProcessor::DisableHostgroupPassiveHostChecks(double, const s BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { Service::Ptr hc = host->GetCheckService(); - if (!hc) { - Log(LogInformation, "icinga", "Cannot disable passive checks for host '" + host->GetName() + "' which has no check service."); - } else { - Log(LogInformation, "icinga", "Disabling passive checks for host '" + host->GetName() + "'"); + if (!hc) { + Log(LogInformation, "icinga", "Cannot disable passive checks for host '" + host->GetName() + "' which has no check service."); + } else { + Log(LogInformation, "icinga", "Disabling passive checks for host '" + host->GetName() + "'"); - { - ObjectLock olock(hc); + { + ObjectLock olock(hc); - hc->SetEnablePassiveChecks(false); - } - } + hc->SetEnablePassiveChecks(false); + } + } } } @@ -1540,17 +1540,17 @@ void ExternalCommandProcessor::DisableServicegroupHostChecks(double, const std:: Service::Ptr hc = host->GetCheckService(); - if (!hc) { - Log(LogInformation, "icinga", "Cannot disable active checks for host '" + host->GetName() + "' which has no check service."); - } else { - Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'"); + if (!hc) { + Log(LogInformation, "icinga", "Cannot disable active checks for host '" + host->GetName() + "' which has no check service."); + } else { + Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'"); - { - ObjectLock olock(hc); + { + ObjectLock olock(hc); - hc->SetEnableActiveChecks(false); - } - } + hc->SetEnableActiveChecks(false); + } + } } } @@ -1569,17 +1569,17 @@ void ExternalCommandProcessor::DisableServicegroupPassiveHostChecks(double, cons Service::Ptr hc = host->GetCheckService(); - if (!hc) { - Log(LogInformation, "icinga", "Cannot disable passive checks for host '" + host->GetName() + "' which has no check service."); - } else { - Log(LogInformation, "icinga", "Disabling passive checks for host '" + host->GetName() + "'"); + if (!hc) { + Log(LogInformation, "icinga", "Cannot disable passive checks for host '" + host->GetName() + "' which has no check service."); + } else { + Log(LogInformation, "icinga", "Disabling passive checks for host '" + host->GetName() + "'"); - { - ObjectLock olock(hc); + { + ObjectLock olock(hc); - hc->SetEnablePassiveChecks(false); - } - } + hc->SetEnablePassiveChecks(false); + } + } } } @@ -1596,17 +1596,17 @@ void ExternalCommandProcessor::EnableHostgroupHostChecks(double, const std::vect BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { Service::Ptr hc = host->GetCheckService(); - if (!hc) { - Log(LogInformation, "icinga", "Cannot enable active checks for host '" + host->GetName() + "' which has no check service."); - } else { - Log(LogInformation, "icinga", "Enabling active checks for host '" + host->GetName() + "'"); + if (!hc) { + Log(LogInformation, "icinga", "Cannot enable active checks for host '" + host->GetName() + "' which has no check service."); + } else { + Log(LogInformation, "icinga", "Enabling active checks for host '" + host->GetName() + "'"); - { - ObjectLock olock(hc); + { + ObjectLock olock(hc); - hc->SetEnableActiveChecks(true); - } - } + hc->SetEnableActiveChecks(true); + } + } } } @@ -1632,17 +1632,17 @@ void ExternalCommandProcessor::EnableServicegroupHostChecks(double, const std::v Service::Ptr hc = host->GetCheckService(); - if (!hc) { - Log(LogInformation, "icinga", "Cannot enable active checks for host '" + host->GetName() + "' which has no check service."); - } else { - Log(LogInformation, "icinga", "Enabling active checks for host '" + host->GetName() + "'"); + if (!hc) { + Log(LogInformation, "icinga", "Cannot enable active checks for host '" + host->GetName() + "' which has no check service."); + } else { + Log(LogInformation, "icinga", "Enabling active checks for host '" + host->GetName() + "'"); - { - ObjectLock olock(hc); + { + ObjectLock olock(hc); - hc->SetEnableActiveChecks(true); - } - } + hc->SetEnableActiveChecks(true); + } + } } } @@ -1661,17 +1661,17 @@ void ExternalCommandProcessor::EnableServicegroupPassiveHostChecks(double, const Service::Ptr hc = host->GetCheckService(); - if (!hc) { - Log(LogInformation, "icinga", "Cannot enable passive host checks for host '" + host->GetName() + "' which has no check service."); - } else { - Log(LogInformation, "icinga", "Enabling passive checks for host '" + host->GetName() + "'"); + if (!hc) { + Log(LogInformation, "icinga", "Cannot enable passive host checks for host '" + host->GetName() + "' which has no check service."); + } else { + Log(LogInformation, "icinga", "Enabling passive checks for host '" + host->GetName() + "'"); - { - ObjectLock olock(hc); + { + ObjectLock olock(hc); - hc->SetEnablePassiveChecks(false); - } - } + hc->SetEnablePassiveChecks(false); + } + } } } @@ -1687,10 +1687,10 @@ void ExternalCommandProcessor::EnableHostFlapping(double, const std::vectorGetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host flapping for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host flapping for host '" + arguments[0] + "' which has no check service.")); - Log(LogInformation, "icinga", "Enabling flapping detection for host '" + arguments[0] + "'"); + Log(LogInformation, "icinga", "Enabling flapping detection for host '" + arguments[0] + "'"); { ObjectLock olock(hc); @@ -1711,10 +1711,10 @@ void ExternalCommandProcessor::DisableHostFlapping(double, const std::vectorGetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host flapping for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host flapping for host '" + arguments[0] + "' which has no check service.")); - Log(LogInformation, "icinga", "Disabling flapping detection for host '" + arguments[0] + "'"); + Log(LogInformation, "icinga", "Disabling flapping detection for host '" + arguments[0] + "'"); { ObjectLock olock(hc); @@ -1864,10 +1864,10 @@ void ExternalCommandProcessor::ChangeHostModattr(double time, const std::vector< Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update modified attributes for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update modified attributes for host '" + arguments[0] + "' which has no check service.")); - Log(LogInformation, "icinga", "Updating modified attributes for host '" + arguments[0] + "'"); + Log(LogInformation, "icinga", "Updating modified attributes for host '" + arguments[0] + "'"); int modifiedAttributes = Convert::ToLong(arguments[1]); @@ -1911,10 +1911,10 @@ void ExternalCommandProcessor::ChangeNormalHostCheckInterval(double time, const Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update check interval for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update check interval for host '" + arguments[0] + "' which has no check service.")); - Log(LogInformation, "icinga", "Updating check interval for host '" + arguments[0] + "'"); + Log(LogInformation, "icinga", "Updating check interval for host '" + arguments[0] + "'"); double interval = Convert::ToDouble(arguments[1]); @@ -1958,10 +1958,10 @@ void ExternalCommandProcessor::ChangeRetryHostCheckInterval(double time, const s Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update retry interval for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update retry interval for host '" + arguments[0] + "' which has no check service.")); - Log(LogInformation, "icinga", "Updating retry interval for host '" + arguments[0] + "'"); + Log(LogInformation, "icinga", "Updating retry interval for host '" + arguments[0] + "'"); double interval = Convert::ToDouble(arguments[1]); @@ -1984,8 +1984,8 @@ void ExternalCommandProcessor::EnableHostEventHandler(double time, const std::ve Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable event handler for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable event handler for host '" + arguments[0] + "' which has no check service.")); Log(LogInformation, "icinga", "Enabling event handler for host '" + arguments[0] + "'"); @@ -2008,8 +2008,8 @@ void ExternalCommandProcessor::DisableHostEventHandler(double time, const std::v Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable event handler for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable event handler for host '" + arguments[0] + "' which has no check service.")); Log(LogInformation, "icinga", "Disabling event handler for host '" + arguments[0] + "'"); @@ -2070,8 +2070,8 @@ void ExternalCommandProcessor::ChangeHostEventHandler(double time, const std::ve Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change event handler for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + 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[2]); @@ -2123,8 +2123,8 @@ void ExternalCommandProcessor::ChangeHostCheckCommand(double time, const std::ve Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change check command for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change check command for host '" + arguments[0] + "' which has no check service.")); CheckCommand::Ptr command = CheckCommand::GetByName(arguments[2]); @@ -2176,8 +2176,8 @@ void ExternalCommandProcessor::ChangeMaxHostCheckAttempts(double time, const std Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change max check attempts for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change max check attempts for host '" + arguments[0] + "' which has no check service.")); int attempts = Convert::ToLong(arguments[2]); @@ -2223,8 +2223,8 @@ void ExternalCommandProcessor::ChangeHostCheckTimeperiod(double time, const std: Service::Ptr hc = host->GetCheckService(); - if (!hc) - BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change check period for host '" + arguments[0] + "' which has no check service.")); + if (!hc) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change check period for host '" + arguments[0] + "' which has no check service.")); TimePeriod::Ptr tp = TimePeriod::GetByName(arguments[2]);