@using System.Text.Json @using MoonlightServers.Shared.Http.Responses.Admin.Nodes @implements IDisposable @inject HttpApiClient HttpApiClient
@if (IsOffline) { } else { @*

Node overview

See all important details of this node at one quick look

*@ var cpuUsage = Math.Round(Status.CpuUsage.Average(x => x), 2) + "%"; var memoryUsage = $"{Formatter.FormatSize((long)(Status.MemoryTotal - Status.MemoryAvailable))} / {Formatter.FormatSize((long)Status.MemoryTotal)}"; var uptime = Formatter.FormatUptime(Status.Uptime); var diskUsage = $"{Formatter.FormatSize((long)(Status.DiskTotal - Status.DiskFree))} / {Formatter.FormatSize((long)Status.DiskTotal)}";

CPU Cores

View the nodes cpu usage in detail

@{ int index = 1; } @foreach (var usage in Status.CpuUsage) { index++; }
}
@code { [Parameter] public int NodeId { get; set; } private bool IsOffline = false; private bool KeepRefreshing = true; private StatusNodeResponse Status; private async Task Load(LazyLoader arg) { await UpdateStatus(); Task.Run(async () => { while (KeepRefreshing) { await UpdateStatus(); await InvokeAsync(StateHasChanged); await Task.Delay(TimeSpan.FromSeconds(1)); } }); } private async Task UpdateStatus() { IsOffline = false; try { Status = await HttpApiClient.GetJson($"admin/servers/nodes/{NodeId}/status"); Console.WriteLine(JsonSerializer.Serialize(Status)); } catch (Exception) { IsOffline = true; } } public void Dispose() { KeepRefreshing = false; } }