X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=lib%2Ficinga%2Fexternalcommandprocessor.cpp;h=538d60a91e516415f655304f9691307b5e305e35;hb=f1d2548fc0581832294d3e2a4f559a9ceeff897a;hp=b0430517be4063d30b920377fd7bdffb224d8134;hpb=0bb0711d7268dd3e0bdc6ddb95eed2fd762abbf7;p=icinga2 diff --git a/lib/icinga/externalcommandprocessor.cpp b/lib/icinga/externalcommandprocessor.cpp index b0430517b..538d60a91 100644 --- a/lib/icinga/externalcommandprocessor.cpp +++ b/lib/icinga/externalcommandprocessor.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * Icinga 2 * - * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -17,13 +17,23 @@ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ******************************************************************************/ -#include "i2-icinga.h" +#include "icinga/externalcommandprocessor.h" +#include "icinga/host.h" +#include "icinga/service.h" +#include "icinga/user.h" +#include "icinga/hostgroup.h" +#include "icinga/servicegroup.h" +#include "icinga/pluginchecktask.h" #include "base/convert.h" #include "base/logger_fwd.h" #include "base/objectlock.h" +#include "base/application.h" +#include "base/utility.h" +#include #include #include #include +#include using namespace icinga; @@ -31,9 +41,6 @@ boost::once_flag ExternalCommandProcessor::m_InitializeOnce = BOOST_ONCE_INIT; boost::mutex ExternalCommandProcessor::m_Mutex; std::map ExternalCommandProcessor::m_Commands; -/** - * @threadsafety Always. - */ void ExternalCommandProcessor::Execute(const String& line) { if (line.IsEmpty()) @@ -55,7 +62,8 @@ void ExternalCommandProcessor::Execute(const String& line) if (ts == 0) BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid timestamp in command: " + line)); - std::vector argv = args.Split(boost::is_any_of(";")); + std::vector argv; + boost::algorithm::split(argv, args, boost::is_any_of(";")); if (argv.empty()) BOOST_THROW_EXCEPTION(std::invalid_argument("Missing arguments in command: " + line)); @@ -64,9 +72,6 @@ void ExternalCommandProcessor::Execute(const String& line) Execute(ts, argv[0], argvExtra); } -/** - * @threadsafety Always. - */ void ExternalCommandProcessor::Execute(double time, const String& command, const std::vector& arguments) { boost::call_once(m_InitializeOnce, &ExternalCommandProcessor::Initialize); @@ -88,9 +93,6 @@ void ExternalCommandProcessor::Execute(double time, const String& command, const callback(time, arguments); } -/** - * @threadsafety Always. - */ void ExternalCommandProcessor::Initialize(void) { RegisterCommand("PROCESS_HOST_CHECK_RESULT", &ExternalCommandProcessor::ProcessHostCheckResult); @@ -104,6 +106,7 @@ void ExternalCommandProcessor::Initialize(void) RegisterCommand("ENABLE_SVC_CHECK", &ExternalCommandProcessor::EnableSvcCheck); RegisterCommand("DISABLE_SVC_CHECK", &ExternalCommandProcessor::DisableSvcCheck); RegisterCommand("SHUTDOWN_PROCESS", &ExternalCommandProcessor::ShutdownProcess); + RegisterCommand("RESTART_PROCESS", &ExternalCommandProcessor::RestartProcess); RegisterCommand("SCHEDULE_FORCED_HOST_SVC_CHECKS", &ExternalCommandProcessor::ScheduleForcedHostSvcChecks); RegisterCommand("SCHEDULE_HOST_SVC_CHECKS", &ExternalCommandProcessor::ScheduleHostSvcChecks); RegisterCommand("ENABLE_HOST_SVC_CHECKS", &ExternalCommandProcessor::EnableHostSvcChecks); @@ -114,6 +117,10 @@ void ExternalCommandProcessor::Initialize(void) RegisterCommand("ACKNOWLEDGE_HOST_PROBLEM", &ExternalCommandProcessor::AcknowledgeHostProblem); RegisterCommand("ACKNOWLEDGE_HOST_PROBLEM_EXPIRE", &ExternalCommandProcessor::AcknowledgeHostProblemExpire); RegisterCommand("REMOVE_HOST_ACKNOWLEDGEMENT", &ExternalCommandProcessor::RemoveHostAcknowledgement); + RegisterCommand("DISABLE_HOST_FLAP_DETECTION", &ExternalCommandProcessor::DisableHostFlapping); + RegisterCommand("ENABLE_HOST_FLAP_DETECTION", &ExternalCommandProcessor::EnableHostFlapping); + RegisterCommand("DISABLE_SVC_FLAP_DETECTION", &ExternalCommandProcessor::DisableSvcFlapping); + RegisterCommand("ENABLE_SVC_FLAP_DETECTION", &ExternalCommandProcessor::EnableSvcFlapping); RegisterCommand("ENABLE_HOSTGROUP_SVC_CHECKS", &ExternalCommandProcessor::EnableHostgroupSvcChecks); RegisterCommand("DISABLE_HOSTGROUP_SVC_CHECKS", &ExternalCommandProcessor::DisableHostgroupSvcChecks); RegisterCommand("ENABLE_SERVICEGROUP_SVC_CHECKS", &ExternalCommandProcessor::EnableServicegroupSvcChecks); @@ -150,11 +157,16 @@ void ExternalCommandProcessor::Initialize(void) RegisterCommand("DISABLE_HOST_NOTIFICATIONS", &ExternalCommandProcessor::DisableHostNotifications); RegisterCommand("ENABLE_SVC_NOTIFICATIONS", &ExternalCommandProcessor::EnableSvcNotifications); RegisterCommand("DISABLE_SVC_NOTIFICATIONS", &ExternalCommandProcessor::DisableSvcNotifications); + RegisterCommand("DISABLE_HOSTGROUP_HOST_CHECKS", &ExternalCommandProcessor::DisableHostgroupHostChecks); + RegisterCommand("DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS", &ExternalCommandProcessor::DisableHostgroupPassiveHostChecks); + RegisterCommand("DISABLE_SERVICEGROUP_HOST_CHECKS", &ExternalCommandProcessor::DisableServicegroupHostChecks); + RegisterCommand("DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS", &ExternalCommandProcessor::DisableServicegroupPassiveHostChecks); + RegisterCommand("ENABLE_HOSTGROUP_HOST_CHECKS", &ExternalCommandProcessor::EnableHostgroupHostChecks); + RegisterCommand("ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS", &ExternalCommandProcessor::EnableHostgroupPassiveHostChecks); + RegisterCommand("ENABLE_SERVICEGROUP_HOST_CHECKS", &ExternalCommandProcessor::EnableServicegroupHostChecks); + RegisterCommand("ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS", &ExternalCommandProcessor::EnableServicegroupPassiveHostChecks); } -/** - * @threadsafety Always. - */ void ExternalCommandProcessor::RegisterCommand(const String& command, const ExternalCommandProcessor::Callback& callback) { boost::mutex::scoped_lock lock(m_Mutex); @@ -168,7 +180,10 @@ void ExternalCommandProcessor::ProcessHostCheckResult(double time, const std::ve Host::Ptr host = Host::GetByName(arguments[0]); - Service::Ptr hc = host->GetHostCheckService(); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot passive host check result for non-existent host '" + arguments[0] + "'")); + + Service::Ptr hc = host->GetCheckService(); if (!hc->GetEnablePassiveChecks()) BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for host '" + arguments[0] + "' which has passive checks disabled.")); @@ -203,6 +218,9 @@ void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std: Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot process passive service check result for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + if (!service->GetEnablePassiveChecks()) BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for service '" + arguments[1] + "' which has passive checks disabled.")); @@ -236,7 +254,16 @@ void ExternalCommandProcessor::ScheduleHostCheck(double, const std::vectorGetHostCheckService(); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule host check for non-existent host '" + arguments[0] + "'")); + + Service::Ptr hc = host->GetCheckService(); + + if (!hc) { + Log(LogInformation, "icinga", "Ignoring request request for host '" + + arguments[0] + "' (does not have a host check)"); + return; + } double planned_check = Convert::ToDouble(arguments[1]); @@ -248,6 +275,9 @@ void ExternalCommandProcessor::ScheduleHostCheck(double, const std::vectorGetHostCheckService(); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule forced host check for non-existent host '" + arguments[0] + "'")); + + Service::Ptr hc = host->GetCheckService(); + + if (!hc) { + Log(LogInformation, "icinga", "Ignoring request request for host '" + + arguments[0] + "' (does not have a host check)"); + return; + } Log(LogInformation, "icinga", "Rescheduling next check for host '" + arguments[0] + "'"); @@ -281,6 +320,9 @@ void ExternalCommandProcessor::ScheduleSvcCheck(double, const std::vector service->GetNextCheck()) { @@ -291,6 +333,9 @@ void ExternalCommandProcessor::ScheduleSvcCheck(double, const std::vector Host::Ptr host = Host::GetByName(arguments[0]); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host check non-existent host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Enabling active checks for host '" + arguments[0] + "'"); - Service::Ptr hc = host->GetHostCheckService(); + Service::Ptr hc = host->GetCheckService(); if (!hc) return; @@ -342,8 +393,11 @@ void ExternalCommandProcessor::DisableHostCheck(double, const std::vectorGetHostCheckService(); + Service::Ptr hc = host->GetCheckService(); if (!hc) return; @@ -362,6 +416,9 @@ void ExternalCommandProcessor::EnableSvcCheck(double, const std::vector& Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service check for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Enabling active checks for service '" + arguments[1] + "'"); { @@ -378,6 +435,9 @@ void ExternalCommandProcessor::DisableSvcCheck(double, const std::vector Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service check for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Disabling active checks for service '" + arguments[1] + "'"); { @@ -393,6 +453,12 @@ void ExternalCommandProcessor::ShutdownProcess(double, const std::vector Application::RequestShutdown(); } +void ExternalCommandProcessor::RestartProcess(double, const std::vector&) +{ + Log(LogInformation, "icinga", "Restarting Icinga via external command."); + Application::RequestRestart(); +} + void ExternalCommandProcessor::ScheduleForcedHostSvcChecks(double, const std::vector& arguments) { if (arguments.size() < 2) @@ -402,6 +468,9 @@ void ExternalCommandProcessor::ScheduleForcedHostSvcChecks(double, const std::ve Host::Ptr host = Host::GetByName(arguments[0]); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule forced host service checks for non-existent host '" + arguments[0] + "'")); + BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { Log(LogInformation, "icinga", "Rescheduling next check for service '" + service->GetName() + "'"); @@ -423,6 +492,12 @@ void ExternalCommandProcessor::ScheduleHostSvcChecks(double, const std::vectorGetServices()) { if (planned_check > service->GetNextCheck()) { Log(LogInformation, "icinga", "Ignoring reschedule request for service '" + @@ -447,6 +522,9 @@ void ExternalCommandProcessor::EnableHostSvcChecks(double, const std::vectorGetServices()) { Log(LogInformation, "icinga", "Enabling active checks for service '" + service->GetName() + "'"); service->SetEnableActiveChecks(true); @@ -460,6 +538,9 @@ void ExternalCommandProcessor::DisableHostSvcChecks(double, const std::vectorGetServices()) { Log(LogInformation, "icinga", "Disabling active checks for service '" + service->GetName() + "'"); @@ -480,12 +561,16 @@ void ExternalCommandProcessor::AcknowledgeSvcProblem(double, const std::vectorGetState() == StateOK) BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arguments[1] + "' is OK.")); Log(LogInformation, "icinga", "Setting acknowledgement for service '" + service->GetName() + "'"); - service->AcknowledgeProblem(sticky ? AcknowledgementSticky : AcknowledgementNormal); + service->AddComment(CommentAcknowledgement, arguments[5], arguments[6], 0); + service->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal); } void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const std::vector& arguments) @@ -498,12 +583,16 @@ void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const std::ve Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge service problem with expire time for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + if (service->GetState() == StateOK) BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arguments[1] + "' is OK.")); Log(LogInformation, "icinga", "Setting timed acknowledgement for service '" + service->GetName() + "'"); - service->AcknowledgeProblem(sticky ? AcknowledgementSticky : AcknowledgementNormal, timestamp); + service->AddComment(CommentAcknowledgement, arguments[6], arguments[7], 0); + service->AcknowledgeProblem(arguments[6], arguments[7], sticky ? AcknowledgementSticky : AcknowledgementNormal, timestamp); } void ExternalCommandProcessor::RemoveSvcAcknowledgement(double, const std::vector& arguments) @@ -513,6 +602,9 @@ void ExternalCommandProcessor::RemoveSvcAcknowledgement(double, const std::vecto Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot remove service acknowledgement for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Removing acknowledgement for service '" + service->GetName() + "'"); service->ClearAcknowledgement(); @@ -527,13 +619,17 @@ void ExternalCommandProcessor::AcknowledgeHostProblem(double, const std::vector< Host::Ptr host = Host::GetByName(arguments[0]); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge host problem for non-existent host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Setting acknowledgement for host '" + host->GetName() + "'"); - Service::Ptr service = host->GetHostCheckService(); + Service::Ptr service = host->GetCheckService(); if (service) { if (service->GetState() == StateOK) BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK.")); - service->AcknowledgeProblem(sticky ? AcknowledgementSticky : AcknowledgementNormal); + service->AddComment(CommentAcknowledgement, arguments[4], arguments[5], 0); + service->AcknowledgeProblem(arguments[4], arguments[5], sticky ? AcknowledgementSticky : AcknowledgementNormal); } } @@ -547,13 +643,17 @@ void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const std::v Host::Ptr host = Host::GetByName(arguments[0]); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge host problem with expire time for non-existent host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Setting timed acknowledgement for host '" + host->GetName() + "'"); - Service::Ptr service = host->GetHostCheckService(); + Service::Ptr service = host->GetCheckService(); if (service) { if (service->GetState() == StateOK) BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK.")); - service->AcknowledgeProblem(sticky ? AcknowledgementSticky : AcknowledgementNormal, timestamp); + service->AddComment(CommentAcknowledgement, arguments[5], arguments[6], 0); + service->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal, timestamp); } } @@ -564,8 +664,11 @@ void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const std::vect Host::Ptr host = Host::GetByName(arguments[0]); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot remove acknowledgement for non-existent host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Removing acknowledgement for host '" + host->GetName() + "'"); - Service::Ptr service = host->GetHostCheckService(); + Service::Ptr service = host->GetCheckService(); if (service) service->ClearAcknowledgement(); } @@ -577,6 +680,9 @@ void ExternalCommandProcessor::EnableHostgroupSvcChecks(double, const std::vecto HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]); + if (!hg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgroup service checks for non-existent hostgroup '" + arguments[0] + "'")); + BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { Log(LogInformation, "icinga", "Enabling active checks for service '" + service->GetName() + "'"); @@ -597,6 +703,9 @@ void ExternalCommandProcessor::DisableHostgroupSvcChecks(double, const std::vect HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]); + if (!hg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup service checks for non-existent hostgroup '" + arguments[0] + "'")); + BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { Log(LogInformation, "icinga", "Disabling active checks for service '" + service->GetName() + "'"); @@ -617,6 +726,9 @@ void ExternalCommandProcessor::EnableServicegroupSvcChecks(double, const std::ve ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]); + if (!sg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup service checks for non-existent servicegroup '" + arguments[0] + "'")); + BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { Log(LogInformation, "icinga", "Enabling active checks for service '" + service->GetName() + "'"); @@ -635,6 +747,9 @@ void ExternalCommandProcessor::DisableServicegroupSvcChecks(double, const std::v ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]); + if (!sg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup service checks for non-existent servicegroup '" + arguments[0] + "'")); + BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { Log(LogInformation, "icinga", "Disabling active checks for service '" + service->GetName() + "'"); @@ -653,8 +768,11 @@ void ExternalCommandProcessor::EnablePassiveHostChecks(double, const std::vector Host::Ptr host = Host::GetByName(arguments[0]); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable passive host checks for non-existent host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Enabling passive checks for host '" + arguments[0] + "'"); - Service::Ptr hc = host->GetHostCheckService(); + Service::Ptr hc = host->GetCheckService(); if (!hc) return; @@ -673,8 +791,11 @@ void ExternalCommandProcessor::DisablePassiveHostChecks(double, const std::vecto Host::Ptr host = Host::GetByName(arguments[0]); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable passive host checks for non-existent host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Disabling passive checks for host '" + arguments[0] + "'"); - Service::Ptr hc = host->GetHostCheckService(); + Service::Ptr hc = host->GetCheckService(); if (!hc) return; @@ -693,6 +814,9 @@ void ExternalCommandProcessor::EnablePassiveSvcChecks(double, const std::vector< Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service checks for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Enabling passive checks for service '" + arguments[1] + "'"); { @@ -709,6 +833,9 @@ void ExternalCommandProcessor::DisablePassiveSvcChecks(double, const std::vector Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service checks for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Disabling passive checks for service '" + arguments[1] + "'"); { @@ -725,6 +852,9 @@ void ExternalCommandProcessor::EnableServicegroupPassiveSvcChecks(double, const ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]); + if (!sg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup passive service checks for non-existent servicegroup '" + arguments[0] + "'")); + BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { Log(LogInformation, "icinga", "Enabling passive checks for service '" + service->GetName() + "'"); @@ -743,6 +873,9 @@ void ExternalCommandProcessor::DisableServicegroupPassiveSvcChecks(double, const ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]); + if (!sg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup passive service checks for non-existent servicegroup '" + arguments[0] + "'")); + BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { Log(LogInformation, "icinga", "Disabling passive checks for service '" + service->GetName() + "'"); @@ -761,6 +894,9 @@ void ExternalCommandProcessor::EnableHostgroupPassiveSvcChecks(double, const std HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]); + if (!hg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgroup passive service checks for non-existent hostgroup '" + arguments[0] + "'")); + BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { Log(LogInformation, "icinga", "Enabling passive checks for service '" + service->GetName() + "'"); @@ -781,6 +917,9 @@ void ExternalCommandProcessor::DisableHostgroupPassiveSvcChecks(double, const st HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]); + if (!hg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup passive service checks for non-existent hostgroup '" + arguments[0] + "'")); + BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { Log(LogInformation, "icinga", "Disabling passive checks for service '" + service->GetName() + "'"); @@ -835,13 +974,17 @@ void ExternalCommandProcessor::ScheduleSvcDowntime(double, const std::vectorGetName()); - (void) service->AddDowntime(arguments[7], arguments[8], + String comment_id = service->AddComment(CommentDowntime, arguments[7], arguments[8], Convert::ToDouble(arguments[3])); + (void) service->AddDowntime(comment_id, Convert::ToDouble(arguments[2]), Convert::ToDouble(arguments[3]), Convert::ToBool(arguments[4]), triggeredBy, Convert::ToDouble(arguments[6])); } @@ -854,7 +997,7 @@ void ExternalCommandProcessor::DelSvcDowntime(double, const std::vector& int id = Convert::ToLong(arguments[0]); Log(LogInformation, "icinga", "Removing downtime ID " + arguments[0]); String rid = Service::GetDowntimeIDFromLegacyID(id); - Service::RemoveDowntime(rid); + Service::RemoveDowntime(rid, true); } void ExternalCommandProcessor::ScheduleHostDowntime(double, const std::vector& arguments) @@ -864,15 +1007,19 @@ void ExternalCommandProcessor::ScheduleHostDowntime(double, const std::vectorGetName()); - Service::Ptr service = host->GetHostCheckService(); + Service::Ptr service = host->GetCheckService(); if (service) { - (void) service->AddDowntime(arguments[6], arguments[7], + String comment_id = service->AddComment(CommentDowntime, arguments[6], arguments[7], Convert::ToDouble(arguments[2])); + (void) service->AddDowntime(comment_id, Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]), Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5])); } @@ -886,7 +1033,7 @@ void ExternalCommandProcessor::DelHostDowntime(double, const std::vector int id = Convert::ToLong(arguments[0]); Log(LogInformation, "icinga", "Removing downtime ID " + arguments[0]); String rid = Service::GetDowntimeIDFromLegacyID(id); - Service::RemoveDowntime(rid); + Service::RemoveDowntime(rid, true); } void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const std::vector& arguments) @@ -896,6 +1043,9 @@ void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const std::vector Host::Ptr host = Host::GetByName(arguments[0]); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule host services downtime for non-existent host '" + arguments[0] + "'")); + String triggeredBy; int triggeredByLegacy = Convert::ToLong(arguments[4]); if (triggeredByLegacy != 0) @@ -903,7 +1053,8 @@ void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const std::vector BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { Log(LogInformation, "icinga", "Creating downtime for service " + service->GetName()); - (void) service->AddDowntime(arguments[6], arguments[7], + String comment_id = service->AddComment(CommentDowntime, arguments[6], arguments[7], Convert::ToDouble(arguments[2])); + (void) service->AddDowntime(comment_id, Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]), Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5])); } @@ -916,6 +1067,9 @@ void ExternalCommandProcessor::ScheduleHostgroupHostDowntime(double, const std:: HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]); + if (!hg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule hostgroup host downtime for non-existent hostgroup '" + arguments[0] + "'")); + String triggeredBy; int triggeredByLegacy = Convert::ToLong(arguments[4]); if (triggeredByLegacy != 0) @@ -923,9 +1077,10 @@ void ExternalCommandProcessor::ScheduleHostgroupHostDowntime(double, const std:: BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { Log(LogInformation, "icinga", "Creating downtime for host " + host->GetName()); - Service::Ptr service = host->GetHostCheckService(); + Service::Ptr service = host->GetCheckService(); if (service) { - (void) service->AddDowntime(arguments[6], arguments[7], + String comment_id = service->AddComment(CommentDowntime, arguments[6], arguments[7], Convert::ToDouble(arguments[2])); + (void) service->AddDowntime(comment_id, Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]), Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5])); } @@ -939,6 +1094,9 @@ void ExternalCommandProcessor::ScheduleHostgroupSvcDowntime(double, const std::v HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]); + if (!hg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule hostgroup service downtime for non-existent hostgroup '" + arguments[0] + "'")); + String triggeredBy; int triggeredByLegacy = Convert::ToLong(arguments[4]); if (triggeredByLegacy != 0) @@ -958,7 +1116,8 @@ void ExternalCommandProcessor::ScheduleHostgroupSvcDowntime(double, const std::v BOOST_FOREACH(const Service::Ptr& service, services) { Log(LogInformation, "icinga", "Creating downtime for service " + service->GetName()); - (void) service->AddDowntime(arguments[6], arguments[7], + String comment_id = service->AddComment(CommentDowntime, arguments[6], arguments[7], Convert::ToDouble(arguments[2])); + (void) service->AddDowntime(comment_id, Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]), Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5])); } @@ -971,6 +1130,9 @@ void ExternalCommandProcessor::ScheduleServicegroupHostDowntime(double, const st ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]); + if (!sg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule servicegroup host downtime for non-existent servicegroup '" + arguments[0] + "'")); + String triggeredBy; int triggeredByLegacy = Convert::ToLong(arguments[4]); if (triggeredByLegacy != 0) @@ -984,14 +1146,15 @@ void ExternalCommandProcessor::ScheduleServicegroupHostDowntime(double, const st BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { Host::Ptr host = service->GetHost(); - Service::Ptr hcService = host->GetHostCheckService(); + Service::Ptr hcService = host->GetCheckService(); if (hcService) services.insert(hcService); } BOOST_FOREACH(const Service::Ptr& service, services) { Log(LogInformation, "icinga", "Creating downtime for service " + service->GetName()); - (void) service->AddDowntime(arguments[6], arguments[7], + String comment_id = service->AddComment(CommentDowntime, arguments[6], arguments[7], Convert::ToDouble(arguments[2])); + (void) service->AddDowntime(comment_id, Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]), Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5])); } @@ -1004,6 +1167,9 @@ void ExternalCommandProcessor::ScheduleServicegroupSvcDowntime(double, const std ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]); + if (!sg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule servicegroup service downtime for non-existent servicegroup '" + arguments[0] + "'")); + String triggeredBy; int triggeredByLegacy = Convert::ToLong(arguments[4]); if (triggeredByLegacy != 0) @@ -1011,7 +1177,8 @@ void ExternalCommandProcessor::ScheduleServicegroupSvcDowntime(double, const std BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { Log(LogInformation, "icinga", "Creating downtime for service " + service->GetName()); - (void) service->AddDowntime(arguments[6], arguments[7], + String comment_id = service->AddComment(CommentDowntime, arguments[6], arguments[7], Convert::ToDouble(arguments[2])); + (void) service->AddDowntime(comment_id, Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]), Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5])); } @@ -1024,8 +1191,11 @@ void ExternalCommandProcessor::AddHostComment(double, const std::vector& Host::Ptr host = Host::GetByName(arguments[0]); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot add host comment for non-existent host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Creating comment for host " + host->GetName()); - Service::Ptr service = host->GetHostCheckService(); + Service::Ptr service = host->GetCheckService(); if (service) (void) service->AddComment(CommentUser, arguments[2], arguments[3], 0); } @@ -1048,6 +1218,9 @@ void ExternalCommandProcessor::AddSvcComment(double, const std::vector& Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot add service comment for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Creating comment for service " + service->GetName()); (void) service->AddComment(CommentUser, arguments[3], arguments[4], 0); } @@ -1071,8 +1244,11 @@ void ExternalCommandProcessor::DelAllHostComments(double, const std::vectorGetName()); - Service::Ptr service = host->GetHostCheckService(); + Service::Ptr service = host->GetCheckService(); if (service) service->RemoveAllComments(); } @@ -1084,6 +1260,9 @@ void ExternalCommandProcessor::DelAllSvcComments(double, const std::vectorGetName()); service->RemoveAllComments(); } @@ -1095,10 +1274,21 @@ void ExternalCommandProcessor::SendCustomHostNotification(double, const std::vec Host::Ptr host = Host::GetByName(arguments[0]); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot send custom host notification for non-existent host '" + arguments[0] + "'")); + + int options = Convert::ToLong(arguments[1]); + Log(LogInformation, "icinga", "Sending custom notification for host " + host->GetName()); - Service::Ptr service = host->GetHostCheckService(); - if (service) - service->RequestNotifications(NotificationCustom, service->GetLastCheckResult()); + Service::Ptr service = host->GetCheckService(); + if (service) { + if (options & 2) { + ObjectLock olock(service); + service->SetForceNextNotification(true); + } + + Service::OnNotificationsRequested(service, NotificationCustom, service->GetLastCheckResult(), arguments[2], arguments[3]); + } } void ExternalCommandProcessor::SendCustomSvcNotification(double, const std::vector& arguments) @@ -1108,8 +1298,19 @@ void ExternalCommandProcessor::SendCustomSvcNotification(double, const std::vect Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot send custom service notification for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + + int options = Convert::ToLong(arguments[2]); + Log(LogInformation, "icinga", "Sending custom notification for service " + service->GetName()); - service->RequestNotifications(NotificationCustom, service->GetLastCheckResult()); + + if (options & 2) { + ObjectLock olock(service); + service->SetForceNextNotification(true); + } + + Service::OnNotificationsRequested(service, NotificationCustom, service->GetLastCheckResult(), arguments[3], arguments[4]); } void ExternalCommandProcessor::DelayHostNotification(double, const std::vector& arguments) @@ -1119,15 +1320,18 @@ void ExternalCommandProcessor::DelayHostNotification(double, const std::vectorGetName()); - Service::Ptr hc = host->GetHostCheckService(); + Service::Ptr hc = host->GetCheckService(); if (!hc) return; - { - ObjectLock olock(hc); + BOOST_FOREACH(const Notification::Ptr& notification, hc->GetNotifications()) { + ObjectLock olock(notification); - hc->SetLastNotification(Convert::ToDouble(arguments[1])); + notification->SetNextNotification(Convert::ToDouble(arguments[1])); } } @@ -1138,12 +1342,15 @@ void ExternalCommandProcessor::DelaySvcNotification(double, const std::vectorGetName()); - { - ObjectLock olock(service); + BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) { + ObjectLock olock(notification); - service->SetLastNotification(Convert::ToDouble(arguments[2])); + notification->SetNextNotification(Convert::ToDouble(arguments[2])); } } @@ -1154,8 +1361,11 @@ void ExternalCommandProcessor::EnableHostNotifications(double, const std::vector Host::Ptr host = Host::GetByName(arguments[0]); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host notifications for non-existent host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Enabling notifications for host '" + arguments[0] + "'"); - Service::Ptr hc = host->GetHostCheckService(); + Service::Ptr hc = host->GetCheckService(); if (!hc) return; @@ -1174,8 +1384,11 @@ void ExternalCommandProcessor::DisableHostNotifications(double, const std::vecto Host::Ptr host = Host::GetByName(arguments[0]); + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host notifications for non-existent host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Disabling notifications for host '" + arguments[0] + "'"); - Service::Ptr hc = host->GetHostCheckService(); + Service::Ptr hc = host->GetCheckService(); if (!hc) return; @@ -1194,6 +1407,9 @@ void ExternalCommandProcessor::EnableSvcNotifications(double, const std::vector< Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service notifications for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Enabling notifications for service '" + arguments[1] + "'"); { @@ -1210,6 +1426,9 @@ void ExternalCommandProcessor::DisableSvcNotifications(double, const std::vector Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service notifications for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + Log(LogInformation, "icinga", "Disabling notifications for service '" + arguments[1] + "'"); { @@ -1218,3 +1437,296 @@ void ExternalCommandProcessor::DisableSvcNotifications(double, const std::vector service->SetEnableNotifications(false); } } + +void ExternalCommandProcessor::DisableHostgroupHostChecks(double, const std::vector& arguments) +{ + if (arguments.size() < 1) + BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 1 arguments.")); + + HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]); + + if (!hg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup host checks for non-existent hostgroup '" + arguments[0] + "'")); + + BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + Service::Ptr hc = host->GetCheckService(); + + if (!hc) + continue; + + Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'"); + + { + ObjectLock olock(hc); + + hc->SetEnableActiveChecks(false); + } + } +} + +void ExternalCommandProcessor::DisableHostgroupPassiveHostChecks(double, const std::vector& arguments) +{ + if (arguments.size() < 1) + BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 1 arguments.")); + + HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]); + + if (!hg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup passive host checks for non-existent hostgroup '" + arguments[0] + "'")); + + BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + Service::Ptr hc = host->GetCheckService(); + + if (!hc) + continue; + + Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'"); + + { + ObjectLock olock(hc); + + hc->SetEnablePassiveChecks(false); + } + } +} + +void ExternalCommandProcessor::DisableServicegroupHostChecks(double, const std::vector& arguments) +{ + if (arguments.size() < 1) + BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 1 arguments.")); + + ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]); + + if (!sg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup host checks for non-existent servicegroup '" + arguments[0] + "'")); + + BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + Host::Ptr host = service->GetHost(); + + if (!host) + continue; + + Service::Ptr hc = host->GetCheckService(); + + if (!hc) + continue; + + Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'"); + + { + ObjectLock olock(hc); + + hc->SetEnableActiveChecks(false); + } + } +} + +void ExternalCommandProcessor::DisableServicegroupPassiveHostChecks(double, const std::vector& arguments) +{ + if (arguments.size() < 1) + BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 1 arguments.")); + + ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]); + + if (!sg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup passive host checks for non-existent servicegroup '" + arguments[0] + "'")); + + BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + Host::Ptr host = service->GetHost(); + + if (!host) + continue; + + Service::Ptr hc = host->GetCheckService(); + + if (!hc) + continue; + + Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'"); + + { + ObjectLock olock(hc); + + hc->SetEnablePassiveChecks(false); + } + } +} + +void ExternalCommandProcessor::EnableHostgroupHostChecks(double, const std::vector& arguments) +{ + if (arguments.size() < 1) + BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 1 arguments.")); + + HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]); + + if (!hg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgroup host checks for non-existent hostgroup '" + arguments[0] + "'")); + + BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + Service::Ptr hc = host->GetCheckService(); + + if (!hc) + continue; + + Log(LogInformation, "icinga", "Enabling active checks for host '" + host->GetName() + "'"); + + { + ObjectLock olock(hc); + + hc->SetEnableActiveChecks(true); + } + } +} + +void ExternalCommandProcessor::EnableHostgroupPassiveHostChecks(double, const std::vector& arguments) +{ + if (arguments.size() < 1) + BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 1 arguments.")); + +} + +void ExternalCommandProcessor::EnableServicegroupHostChecks(double, const std::vector& arguments) +{ + if (arguments.size() < 1) + BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 1 arguments.")); + + ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]); + + if (!sg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup host checks for non-existent servicegroup '" + arguments[0] + "'")); + + BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + Host::Ptr host = service->GetHost(); + + if (!host) + continue; + + Service::Ptr hc = host->GetCheckService(); + + if (!hc) + continue; + + Log(LogInformation, "icinga", "Enabling active checks for host '" + host->GetName() + "'"); + + { + ObjectLock olock(hc); + + hc->SetEnableActiveChecks(true); + } + } +} + +void ExternalCommandProcessor::EnableServicegroupPassiveHostChecks(double, const std::vector& arguments) +{ + if (arguments.size() < 1) + BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 1 arguments.")); + + ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]); + + if (!sg) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup passive host checks for non-existent servicegroup '" + arguments[0] + "'")); + + BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + Host::Ptr host = service->GetHost(); + + if (!host) + continue; + + Service::Ptr hc = host->GetCheckService(); + + if (!hc) + continue; + + Log(LogInformation, "icinga", "Enabling active checks for host '" + host->GetName() + "'"); + + { + ObjectLock olock(hc); + + hc->SetEnablePassiveChecks(false); + } + } +} + +void ExternalCommandProcessor::EnableHostFlapping(double, const std::vector& arguments) +{ + if (arguments.size() < 1) + BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 1 argument.")); + + Host::Ptr host = Host::GetByName(arguments[0]); + + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host flapping for non-existent host '" + arguments[0] + "'")); + + Log(LogInformation, "icinga", "Enabling flapping detection for host '" + arguments[0] + "'"); + Service::Ptr hc = host->GetCheckService(); + + if (!hc) + return; + + { + ObjectLock olock(hc); + + hc->SetEnableFlapping(true); + } +} + +void ExternalCommandProcessor::DisableHostFlapping(double, const std::vector& arguments) +{ + if (arguments.size() < 1) + BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 1 argument.")); + + Host::Ptr host = Host::GetByName(arguments[0]); + + if (!host) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host flapping for non-existent host '" + arguments[0] + "'")); + + Log(LogInformation, "icinga", "Disabling flapping detection for host '" + arguments[0] + "'"); + Service::Ptr hc = host->GetCheckService(); + + if (!hc) + return; + + { + ObjectLock olock(hc); + + hc->SetEnableFlapping(false); + } +} + +void ExternalCommandProcessor::EnableSvcFlapping(double, const std::vector& arguments) +{ + if (arguments.size() < 2) + BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 2 arguments.")); + + Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service flapping for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + + Log(LogInformation, "icinga", "Enabling flapping detection for service '" + arguments[1] + "'"); + + { + ObjectLock olock(service); + + service->SetEnableFlapping(true); + } +} + +void ExternalCommandProcessor::DisableSvcFlapping(double, const std::vector& arguments) +{ + if (arguments.size() < 2) + BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 2 arguments.")); + + Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]); + + if (!service) + BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service flapping for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'")); + + Log(LogInformation, "icinga", "Disabling flapping detection for service '" + arguments[1] + "'"); + + { + ObjectLock olock(service); + + service->SetEnableFlapping(false); + } +}