From 9d701b7f99b490985123675d499652bc886afb32 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Mon, 12 Mar 2018 16:31:45 +0100 Subject: [PATCH] Use CPU monitoring from ATxCommon.Monitoring. --- ATxDiagnostics/ATxDiagnostics.cs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/ATxDiagnostics/ATxDiagnostics.cs b/ATxDiagnostics/ATxDiagnostics.cs index 83c7995..f3efa13 100644 --- a/ATxDiagnostics/ATxDiagnostics.cs +++ b/ATxDiagnostics/ATxDiagnostics.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.Management; using ATxCommon; +using ATxCommon.Monitoring; using NLog; using NLog.Config; using NLog.Targets; @@ -28,10 +29,16 @@ namespace ATxDiagnostics logConfig.LoggingRules.Add(logRuleConsole); LogManager.Configuration = logConfig; - GetCpuCounter(); - Log.Debug(SystemChecks.GetCpuUsage()); - Log.Debug(QueryCpuLoad()); Log.Debug("Free space on drive [C:]: " + Conv.BytesToString(SystemChecks.GetFreeDriveSpace("C:"))); + var cpu = new Cpu { + Interval = 250, + Limit = 25, + Probation = 16, + Enabled = true + }; + while (true) { + System.Threading.Thread.Sleep(1000); + } } private static int QueryCpuLoad() { @@ -74,18 +81,5 @@ namespace ATxDiagnostics return usageInt32; } - private static void GetCpuCounter() { - var counter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); - var i = 0; - while (true) { - i++; - //Log.Debug("PerformanceCounter reading {1}: {0}", counter.NextValue(), i); - var watch = Stopwatch.StartNew(); - var reading = counter.NextValue(); - watch.Stop(); - Console.WriteLine("reading {1} (took {2} ms): {0}", reading, i, watch.ElapsedMilliseconds); - System.Threading.Thread.Sleep(250); - } - } } } -- GitLab