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;