From: Gunnar Beutner Date: Tue, 22 Jan 2013 11:56:29 +0000 (+0100) Subject: Implemented the external commands SCHEDULE_SVC_CHECK and SCHEDULE_FORCED_SVC_CHECK. X-Git-Tag: v0.0.2~685 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ed49bd6e1d1ab6b0c193a328a04c6751bd2dc52;p=icinga2 Implemented the external commands SCHEDULE_SVC_CHECK and SCHEDULE_FORCED_SVC_CHECK. --- diff --git a/lib/icinga/externalcommand.cpp b/lib/icinga/externalcommand.cpp index 131c46678..8784e693a 100644 --- a/lib/icinga/externalcommand.cpp +++ b/lib/icinga/externalcommand.cpp @@ -29,6 +29,8 @@ int ExternalCommand::Execute(double time, const String& command, const vector return 0; } + +int ExternalCommand::ScheduleSvcCheck(double time, const vector& arguments) +{ + if (arguments.size() < 3) + return -1; + + if (!Service::Exists(arguments[1])) + return -1; + + Service::Ptr service = Service::GetByName(arguments[1]); + + double planned_check = arguments[2].ToDouble(); + + if (planned_check > service->GetNextCheck()) + return -1; + + service->SetNextCheck(planned_check); + + return 0; +} + +int ExternalCommand::ScheduleForcedSvcCheck(double time, const vector& arguments) +{ + if (arguments.size() < 3) + return -1; + + if (!Service::Exists(arguments[1])) + return -1; + + Service::Ptr service = Service::GetByName(arguments[1]); + + // TODO: force checks (once we have time periods) + + service->SetNextCheck(arguments[2].ToDouble()); +} + diff --git a/lib/icinga/externalcommand.h b/lib/icinga/externalcommand.h index 5506ed967..4150c749a 100644 --- a/lib/icinga/externalcommand.h +++ b/lib/icinga/externalcommand.h @@ -30,6 +30,8 @@ public: static int HelloWorld(double time, const vector& arguments); static int ProcessServiceCheckResult(double time, const vector& arguments); + static int ScheduleSvcCheck(double time, const vector& arguments); + static int ScheduleForcedSvcCheck(double time, const vector& arguments); private: typedef function& arguments)> Callback;