]> granicus.if.org Git - icinga2/commitdiff
Replace concurrent_checks in CheckerComponent by global MaxConcurrentChecks
authorNoah Hilverling <noah.hilverling@icinga.com>
Tue, 16 Jan 2018 11:58:45 +0000 (12:58 +0100)
committerNoah Hilverling <noah.hilverling@icinga.com>
Mon, 29 Jan 2018 13:50:24 +0000 (14:50 +0100)
refs #4841

icinga-app/icinga.cpp
lib/base/application.cpp
lib/base/application.hpp
lib/checker/checkercomponent.ti

index 25282e6d83bda52ef79c99cf8920e82b99b7ac25..ef66278187fe8095ad235daa4aad57dacf9e71ca 100644 (file)
@@ -161,6 +161,7 @@ static int Main()
        Application::DeclareRLimitStack(Application::GetDefaultRLimitStack());
 #endif /* __linux__ */
        Application::DeclareConcurrency(std::thread::hardware_concurrency());
+       Application::DeclareMaxConcurrentChecks(Application::GetDefaultMaxConcurrentChecks());
 
        ScriptGlobal::Set("AttachDebugger", false);
 
index 573b92b3b15a06531476cb4c5190d8b6b79bade5..7c552eaeb44012ee0b6e03836e6b602938cafdf9 100644 (file)
@@ -1552,6 +1552,48 @@ int Application::GetConcurrency()
        return ScriptGlobal::Get("Concurrency", &defaultConcurrency);
 }
 
+/**
+ * Sets the max concurrent checks.
+ *
+ * @param maxChecks The new limit.
+ */
+void Application::SetMaxConcurrentChecks(int maxChecks)
+{
+       ScriptGlobal::Set("MaxConcurrentChecks", maxChecks);
+}
+
+/**
+ * Sets the max concurrent checks.
+ *
+ * @param maxChecks The new limit.
+ */
+void Application::DeclareMaxConcurrentChecks(int maxChecks)
+{
+       if (!ScriptGlobal::Exists("MaxConcurrentChecks"))
+               ScriptGlobal::Set("MaxConcurrentChecks", maxChecks);
+}
+
+/**
+ * Retrieves the max concurrent checks.
+ *
+ * @returns The max number of concurrent checks.
+ */
+int Application::GetMaxConcurrentChecks()
+{
+       Value defaultMaxConcurrentChecks = GetDefaultMaxConcurrentChecks();
+       return ScriptGlobal::Get("MaxConcurrentChecks", &defaultMaxConcurrentChecks);
+}
+
+/**
+ * Retrieves the default value for max concurrent checks.
+ *
+ * @returns The default max number of concurrent checks.
+ */
+int Application::GetDefaultMaxConcurrentChecks()
+{
+       return 512;
+}
+
 /**
  * Returns the global thread pool.
  *
index dc54534cc06d0efc26b7587672ad86a27c4d768b..ecdb1e92bdd3c41b3296cfe4ae2921cf2abeb0ae 100644 (file)
@@ -146,6 +146,11 @@ public:
        static int GetConcurrency();
        static void DeclareConcurrency(int ncpus);
 
+       static int GetMaxConcurrentChecks();
+       static int GetDefaultMaxConcurrentChecks();
+       static void DeclareMaxConcurrentChecks(int maxChecks);
+       static void SetMaxConcurrentChecks(int maxChecks);
+
        static ThreadPool& GetTP();
 
        static String GetAppVersion();
index 68fc614fc36e66eaa6cf61e70c5087acccc484a8..119e44252559ab326679e48104128f3b59bce21c 100644 (file)
@@ -27,8 +27,14 @@ namespace icinga
 class CheckerComponent : ConfigObject
 {
        [config] int concurrent_checks {
+               get {{{
+                       return Application::GetMaxConcurrentChecks();
+               }}}
+               set {{{
+                       Application::SetMaxConcurrentChecks(value);
+               }}}
                default {{{
-                       return 512;
+                       return Application::GetDefaultMaxConcurrentChecks();
                }}}
        };
 };