Did some testing. Now able to finish new daemon communication

This commit is contained in:
Marcel Baumgartner
2023-06-07 03:29:36 +02:00
parent f11eef2734
commit 94b8f07d92
3 changed files with 11 additions and 2 deletions

View File

@@ -116,4 +116,12 @@ public static class Formatter
return (i / (1024D * 1024D)).Round(2) + " GB"; return (i / (1024D * 1024D)).Round(2) + " GB";
} }
} }
public static double BytesToGb(long bytes)
{
const double gbMultiplier = 1024 * 1024 * 1024; // 1 GB = 1024 MB * 1024 KB * 1024 B
double gigabytes = (double)bytes / gbMultiplier;
return gigabytes;
}
} }

View File

@@ -5,6 +5,7 @@ using Moonlight.App.ApiClients.Daemon.Resources;
using Moonlight.App.ApiClients.Wings; using Moonlight.App.ApiClients.Wings;
using Moonlight.App.Database.Entities; using Moonlight.App.Database.Entities;
using Moonlight.App.Events; using Moonlight.App.Events;
using Moonlight.App.Helpers;
using Moonlight.App.Repositories; using Moonlight.App.Repositories;
using Moonlight.App.Repositories.Servers; using Moonlight.App.Repositories.Servers;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -84,7 +85,7 @@ public class CleanupService
var cpuMetrics = await nodeService.GetCpuMetrics(node); var cpuMetrics = await nodeService.GetCpuMetrics(node);
var memoryMetrics = await nodeService.GetMemoryMetrics(node); var memoryMetrics = await nodeService.GetMemoryMetrics(node);
if (cpuMetrics.CpuUsage > maxCpu || (memoryMetrics.Total - memoryMetrics.Used) < minMemory) if (cpuMetrics.CpuUsage > maxCpu || (Formatter.BytesToGb(memoryMetrics.Total) - (Formatter.BytesToGb(memoryMetrics.Used))) < minMemory)
{ {
var dockerMetrics = await nodeService.GetDockerMetrics(node); var dockerMetrics = await nodeService.GetDockerMetrics(node);

View File

@@ -87,7 +87,7 @@ else
else else
{ {
<span> <span>
@(Formatter.FormatSize(MemoryMetrics.Used * 1024D * 1024D)) <TL>of</TL> @(Formatter.FormatSize(MemoryMetrics.Total * 1024D * 1024D)) <TL>used</TL> @(Formatter.FormatSize(MemoryMetrics.Used)) <TL>of</TL> @(Formatter.FormatSize(MemoryMetrics.Total)) <TL>memory used</TL>
</span> </span>
} }
</span> </span>