Small fix for node memory calculation
Made calculation accurate using: https://stackoverflow.com/questions/41224738/how-to-calculate-system-memory-usage-from-proc-meminfo-like-htop
This commit is contained in:
parent
efacaa9b86
commit
558e237608
2 changed files with 6 additions and 2 deletions
|
@ -18,7 +18,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 col-12">
|
<div class="col-md-3 col-12">
|
||||||
@{
|
@{
|
||||||
var memoryText = $"{Formatter.FormatSize(Status.Hardware.Memory.Total - Status.Hardware.Memory.Available - Status.Hardware.Memory.Free)} / {Formatter.FormatSize(Status.Hardware.Memory.Total)}";
|
var memoryText = $"{Formatter.FormatSize(Status.Hardware.Memory.Total - (Status.Hardware.Memory.Available + Status.Hardware.Memory.Cached))} / {Formatter.FormatSize(Status.Hardware.Memory.Total)}";
|
||||||
}
|
}
|
||||||
|
|
||||||
<StatCard Value="@memoryText" Description="Memory usage" Icon="bxs-microchip"/>
|
<StatCard Value="@memoryText" Description="Memory usage" Icon="bxs-microchip"/>
|
||||||
|
|
|
@ -78,7 +78,11 @@
|
||||||
@if (NodeStats.ContainsKey(context!.Id) && NodeStats[context.Id] != null)
|
@if (NodeStats.ContainsKey(context!.Id) && NodeStats[context.Id] != null)
|
||||||
{
|
{
|
||||||
var memory = NodeStats[context!.Id]!.Hardware.Memory;
|
var memory = NodeStats[context!.Id]!.Hardware.Memory;
|
||||||
var percent = Math.Round(((float)memory.Total - memory.Available - memory.Free) / memory.Total * 100, 2);
|
|
||||||
|
var used = memory.Total - (memory.Available + memory.Cached);
|
||||||
|
var percent = Math.Round((float) used / memory.Total * 100F, 2);
|
||||||
|
|
||||||
|
//Logger.Debug($"Used: {used} Total: {memory.Total} => {percent}% ({Formatter.FormatSize(used)} / {Formatter.FormatSize(memory.Total)})");
|
||||||
|
|
||||||
<ColoredBar Value="percent"/>
|
<ColoredBar Value="percent"/>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue