Skip to content
Snippets Groups Projects
Commit 9d701b7f authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Use CPU monitoring from ATxCommon.Monitoring.

parent 21e0aeea
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment