From 4fe9cd3145b74fe590a78bf1c64f5df5a0c46dc2 Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Thu, 15 Feb 2018 15:53:21 +0100
Subject: [PATCH] Check for uncommonly high values on certain parameters.

Refers to #28
---
 ATxCommon/Serializables/ServiceConfig.cs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/ATxCommon/Serializables/ServiceConfig.cs b/ATxCommon/Serializables/ServiceConfig.cs
index f021d69..5cd3d90 100644
--- a/ATxCommon/Serializables/ServiceConfig.cs
+++ b/ATxCommon/Serializables/ServiceConfig.cs
@@ -315,6 +315,11 @@ namespace ATxCommon.Serializables
                 return string.Empty;
             }
 
+            void WarnOnHighValue(int value, string name, int thresh) {
+                if (value > thresh)
+                    SubOptimal(value.ToString(), name, "value is set very high, please check!");
+            }
+
             void SubOptimal(string value, string name, string msg) {
                 Log.Warn(">>> Sub-optimal setting detected: <{0}> [{1}] {2}", name, value, msg);
             }
@@ -383,6 +388,14 @@ namespace ATxCommon.Serializables
             ////////// WEAK CHECKS ON PARAMETERS SETTINGS //////////
             // those checks are non-critical and are simply reported to the logs
 
+            WarnOnHighValue(c.ServiceTimer, nameof(c.ServiceTimer), 10000);
+            WarnOnHighValue(c.MaxCpuUsage, nameof(c.MaxCpuUsage), 75);
+            WarnOnHighValue(c.MinAvailableMemory, nameof(c.MinAvailableMemory), 8192);
+            WarnOnHighValue(c.AdminNotificationDelta, nameof(c.AdminNotificationDelta), 1440);
+            WarnOnHighValue(c.GraceNotificationDelta, nameof(c.GraceNotificationDelta), 10080);
+            WarnOnHighValue(c.StorageNotificationDelta, nameof(c.StorageNotificationDelta), 10080);
+            WarnOnHighValue(c.GracePeriod, nameof(c.GracePeriod), 100);
+
             if (!c.DestinationDirectory.StartsWith(@"\\"))
                 SubOptimal(c.DestinationDirectory, "DestinationDirectory", "is not a UNC path!");
 
-- 
GitLab