]> granicus.if.org Git - icinga2/commitdiff
Implemented the external commands SCHEDULE_SVC_CHECK and SCHEDULE_FORCED_SVC_CHECK.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 22 Jan 2013 11:56:29 +0000 (12:56 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 22 Jan 2013 11:56:29 +0000 (12:56 +0100)
lib/icinga/externalcommand.cpp
lib/icinga/externalcommand.h

index 131c4667802e975e6040f04fa97f9b1eca53483a..8784e693abd9db82cb628914094dacebe450926c 100644 (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());
+}
+
index 5506ed96771029019f81edb5f77f98d11905ec2c..4150c749a94c0ba927693fbe9996cdbdca4b2533 100644 (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;