Implemented the external commands SCHEDULE_SVC_CHECK and SCHEDULE_FORCED_SVC_CHECK.

This commit is contained in:
Gunnar Beutner 2013-01-22 12:56:29 +01:00
parent 7e31cb639f
commit 9ed49bd6e1
2 changed files with 40 additions and 0 deletions

View File

@ -29,6 +29,8 @@ int ExternalCommand::Execute(double time, const String& command, const vector<St
if (!m_Initialized) {
RegisterCommand("HELLO_WORLD", &ExternalCommand::HelloWorld);
RegisterCommand("PROCESS_SERVICE_CHECK_RESULT", &ExternalCommand::ProcessServiceCheckResult);
RegisterCommand("SCHEDULE_SVC_CHECK", &ExternalCommand::ScheduleSvcCheck);
RegisterCommand("SCHEDULE_FORCED_SVC_CHECK", &ExternalCommand::ScheduleForcedSvcCheck);
m_Initialized = true;
}
@ -78,3 +80,39 @@ int ExternalCommand::ProcessServiceCheckResult(double time, const vector<String>
return 0;
}
int ExternalCommand::ScheduleSvcCheck(double time, const vector<String>& 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<String>& 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());
}

View File

@ -30,6 +30,8 @@ public:
static int HelloWorld(double time, const vector<String>& arguments);
static int ProcessServiceCheckResult(double time, const vector<String>& arguments);
static int ScheduleSvcCheck(double time, const vector<String>& arguments);
static int ScheduleForcedSvcCheck(double time, const vector<String>& arguments);
private:
typedef function<int (double time, const vector<String>& arguments)> Callback;