From bcd63a2b03603c6eff1d71aa8522718fe7a3fc30 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Thu, 12 Dec 2019 17:27:00 -0800 Subject: [PATCH] Fix Linux memory info. --- Agent/Program.cs | 2 +- Shared/Services/DeviceInformation.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Agent/Program.cs b/Agent/Program.cs index df6264eb..38ad287d 100644 --- a/Agent/Program.cs +++ b/Agent/Program.cs @@ -96,7 +96,7 @@ namespace Remotely.Agent { Logger.Write(ex); } - Thread.Sleep(100); + Thread.Sleep(1000); } } diff --git a/Shared/Services/DeviceInformation.cs b/Shared/Services/DeviceInformation.cs index 0da58552..b30e7c53 100644 --- a/Shared/Services/DeviceInformation.cs +++ b/Shared/Services/DeviceInformation.cs @@ -39,9 +39,10 @@ namespace Remotely.Shared.Services try { var results = OSUtils.StartProcessWithResults("cat", "/proc/meminfo"); - var resultsArr = results.Split('n'); + var resultsArr = results.Split("\n".ToCharArray()); var freeKB = resultsArr - .FirstOrDefault(x => x.StartsWith("MemFree")) + .FirstOrDefault(x => x.Trim().StartsWith("MemFree")) + .Trim() .Split(" ".ToCharArray(), 2) .Last() // 9168236 kB .Trim() @@ -49,7 +50,8 @@ namespace Remotely.Shared.Services .First(); // 9168236 var totalKB = resultsArr - .FirstOrDefault(x => x.StartsWith("MemTotal")) + .FirstOrDefault(x => x.Trim().StartsWith("MemTotal")) + .Trim() .Split(" ".ToCharArray(), 2) .Last() // 16637468 kB .Trim()