Added more host system data

This commit is contained in:
Marcel Baumgartner 2023-03-06 03:31:57 +01:00
parent 1f44becc74
commit e6ac19c4ec
3 changed files with 54 additions and 3 deletions

View file

@ -1,4 +1,5 @@
using System.Runtime.InteropServices; using System.Diagnostics;
using System.Runtime.InteropServices;
using Logging.Net; using Logging.Net;
namespace Moonlight.App.Helpers; namespace Moonlight.App.Helpers;
@ -45,4 +46,19 @@ public class HostSystemHelper
return "N/A"; return "N/A";
} }
} }
public int GetMemoryUsage()
{
var process = Process.GetCurrentProcess();
var bytes = process.WorkingSet64;
return (int)(bytes / (1024.0 * 1024.0));
}
public int GetCpuUsage()
{
var process = Process.GetCurrentProcess();
var cpuTime = process.TotalProcessorTime;
var wallClockTime = DateTime.UtcNow - process.StartTime.ToUniversalTime();
return (int)(100.0 * cpuTime.TotalMilliseconds / wallClockTime.TotalMilliseconds / Environment.ProcessorCount);
}
} }

View file

@ -9,7 +9,7 @@
<AdminSystemNavigation Index="0"/> <AdminSystemNavigation Index="0"/>
<div class="row"> <div class="row">
<div class="col-xxl-6"> <div class="col-xxl-6 my-3">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<span class="card-title"> <span class="card-title">
@ -24,7 +24,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-xxl-6"> <div class="col-xxl-6 my-3">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<span class="card-title"> <span class="card-title">
@ -39,5 +39,36 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-xxl-6 my-3">
<div class="card">
<div class="card-header">
<span class="card-title">
<TL>Memory usage</TL>
</span>
</div>
<div class="card-body">
<span class="fs-5">
<TL>Moonlight is using</TL>
<span class="text-primary">@(HostSystemHelper.GetMemoryUsage()) MB</span>
<TL>of memory</TL>
</span>
</div>
</div>
</div>
<div class="col-xxl-6 my-3">
<div class="card">
<div class="card-header">
<span class="card-title">
<TL>Cpu usage</TL>
</span>
</div>
<div class="card-body">
<span class="fs-5">
<TL>Moonlight is using</TL>
<span class="text-primary">@(HostSystemHelper.GetCpuUsage()) %</span>
</span>
</div>
</div>
</div>
</div> </div>
</OnlyAdmin> </OnlyAdmin>

View file

@ -274,3 +274,7 @@ Version;Version
You are running moonlight version;You are running moonlight version You are running moonlight version;You are running moonlight version
Operating system;Operating system Operating system;Operating system
Moonlight is running on;Moonlight is running on Moonlight is running on;Moonlight is running on
Memory usage;Memory usage
Moonlight is using;Moonlight is using
of memory;of memory
Cpu usage;Cpu usage