feat(agent): télémétrie inventaire matériel — CPU/mémoire/disque/GPU/OS/réseau (Fixes #82 #83 #84 #85) (#137)
## Contexte Implémentation des tickets #82, #83, #84, #85 — télémétrie inventaire matériel agent. L'objectif est de fournir au central un maximum d'informations sur les machines des agents (CPU, mémoire, disques, GPU, OS, réseau, conteneur) sans SSH. ## Changements ### Nouveaux collecteurs (src/Heimdall.Agent/Services/) - **CpuInfoProvider** : parse `/proc/cpuinfo` (vendor, modèle, cœurs physiques/logiques, fréquence, flags AVX/AVX2/FMA/AVX512, cache), topologie, détection cgroup CPU (`/sys/fs/cgroup/cpu.max` v2) - **DiskInventoryProvider** : énumère les montages (`/proc/mounts`), capacité/libre/type SSD/HDD via `/sys/block/*/queue/rotation` - **GpuInventoryProvider** : nvidia-smi, sysfs DRM, vainfo, rocm-smi avec fallback silencieux, multi-GPU - **HostInfoProvider** : os-release, uname, `/proc/uptime` (uptime machine ≠ process), températures sysfs - **ContainerInfoProvider** : détection Docker (/.dockerenv, cgroup), ID conteneur, limites CPU/mémoire ### Refonte SystemMetricsProvider - Séparation host vs process (RAM machine ≠ RAM conteneur ≠ WorkingSet64) - Uptime machine (`/proc/uptime`) distinct de l'uptime process - Mémoire swap ### Entité Agent + Migration - Champs structurés CPU/mémoire/disque/GPU/OS/réseau (tous nullable, rétrocompatible) - Migration EF `AddAgentTelemetryInventory` ### Transport heartbeat - Inventaire au register + refresh périodique (5 min, pas à chaque tick) - Champs JSON pour listes (disques, GPU, interfaces réseau, températures) ### UI Admin (AgentDetail.razor) - Sections CPU, Mémoire/Disques, GPU, Machine/Conteneur avec barres de progression et badges ### Tests - 40+ tests unitaires : providers, handlers, entité Agent - Total : 999 tests verts (Domain 149, Application 397, Agent 210, Web 243) ## Tickets liés - Fixes #82 — CPU inventory - Fixes #83 — Mémoire & disque - Fixes #84 — GPU inventory - Fixes #85 — OS, conteneur, réseau ## Résultats des tests - `dotnet build` : 0 erreur, 0 warning - Domain.Tests : 149 passed - Application.Tests : 397 passed - Agent.Tests : 210 passed - Web.Tests : 243 passed - Total : 999 tests ✅ ## Checklist - [x] `dotnet build` vert (TreatWarningsAsErrors) - [x] Tests unitaires verts - [x] Migration EF créée - [x] Champs nullable (rétrocompatible) - [x] Pas de référence Infrastructure dans les contrôleurs - [x] Collecteurs avec fallback silencieux (pas de crash sans GPU/Docker/sysfs) Reviewed-on: https://forgejo.tordais.cc/nonobis/Heimdall/pulls/137
This commit is contained in:
1 parent
f7e6b0cec3
commit
4792b69e46
63 files changed
+8711
-563
No files matched your search
@@ -4,7 +4,7 @@
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject NavigationManager Nav
|
||||
@implements IDisposable
|
||||
@implements IAsyncDisposable
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-6">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Dns" Class="mr-2" />
|
||||
@@ -99,6 +99,363 @@ else
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
@* ─── Hardware Inventory ─── *@
|
||||
<MudGrid Class="mt-4">
|
||||
@* ─── CPU Inventory ─── *@
|
||||
<MudItem xs="12" md="6">
|
||||
<SectionCard Title="Processeur" Icon="@Icons.Material.Filled.Memory" Elevation="2">
|
||||
<MudGrid>
|
||||
@if (_agent.CpuModel is not null)
|
||||
{
|
||||
<MudItem xs="12">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Modèle</MudText>
|
||||
<MudText Typo="Typo.body1" Class="font-weight-medium">@_agent.CpuModel</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.CpuVendor is not null)
|
||||
{
|
||||
<MudItem xs="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Fabricant</MudText>
|
||||
<MudText Typo="Typo.body1">@_agent.CpuVendor</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.CpuArchitecture is not null)
|
||||
{
|
||||
<MudItem xs="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Architecture</MudText>
|
||||
<MudText Typo="Typo.body1">@_agent.CpuArchitecture</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.PhysicalCores.HasValue)
|
||||
{
|
||||
<MudItem xs="4">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Cœurs physiques</MudText>
|
||||
<MudText Typo="Typo.body1">@_agent.PhysicalCores</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.LogicalCores.HasValue)
|
||||
{
|
||||
<MudItem xs="4">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Cœurs logiques</MudText>
|
||||
<MudText Typo="Typo.body1">@_agent.LogicalCores</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.ThreadsPerCore.HasValue)
|
||||
{
|
||||
<MudItem xs="4">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Threads/noyau</MudText>
|
||||
<MudText Typo="Typo.body1">@_agent.ThreadsPerCore</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.CpuFrequencyMhz.HasValue)
|
||||
{
|
||||
<MudItem xs="6" Class="mt-2">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Fréquence</MudText>
|
||||
<MudText Typo="Typo.body1">@($"{_agent.CpuFrequencyMhz:F0} MHz")</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.CpuCacheBytes.HasValue && _agent.CpuCacheBytes > 0)
|
||||
{
|
||||
<MudItem xs="6" Class="mt-2">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Cache</MudText>
|
||||
<MudText Typo="Typo.body1">@FormatBytes(_agent.CpuCacheBytes.Value)</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(_agent.CpuFlags))
|
||||
{
|
||||
<MudItem xs="12" Class="mt-2">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Instructions clés</MudText>
|
||||
<div class="d-flex flex-wrap gap-1 mt-1">
|
||||
@foreach (var flag in _agent.CpuFlags.Split(',', StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Info" Variant="Variant.Outlined">@flag</MudChip>
|
||||
}
|
||||
</div>
|
||||
</MudItem>
|
||||
}
|
||||
</MudGrid>
|
||||
</SectionCard>
|
||||
</MudItem>
|
||||
|
||||
@* ─── Memory & Disk Inventory ─── *@
|
||||
<MudItem xs="12" md="6">
|
||||
<SectionCard Title="Mémoire & Stockage" Icon="@Icons.Material.Filled.Storage" Elevation="2">
|
||||
<MudGrid>
|
||||
@if (_agent.MemTotalBytes.HasValue)
|
||||
{
|
||||
<MudItem xs="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Mémoire totale</MudText>
|
||||
<MudText Typo="Typo.body1">@FormatBytes(_agent.MemTotalBytes.Value)</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.MemAvailableBytes.HasValue)
|
||||
{
|
||||
<MudItem xs="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Mémoire dispo</MudText>
|
||||
<MudText Typo="Typo.body1">@FormatBytes(_agent.MemAvailableBytes.Value)</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.SwapTotalBytes.HasValue && _agent.SwapTotalBytes > 0)
|
||||
{
|
||||
<MudItem xs="6" Class="mt-2">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Swap total</MudText>
|
||||
<MudText Typo="Typo.body1">@FormatBytes(_agent.SwapTotalBytes.Value)</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.SwapFreeBytes.HasValue && _agent.SwapTotalBytes is > 0)
|
||||
{
|
||||
<MudItem xs="6" Class="mt-2">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Swap dispo</MudText>
|
||||
<MudText Typo="Typo.body1">@FormatBytes(_agent.SwapFreeBytes.Value)</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.ContainerMemoryLimitBytes.HasValue)
|
||||
{
|
||||
<MudItem xs="12" Class="mt-2">
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Warning">
|
||||
Limite conteneur : @FormatBytes(_agent.ContainerMemoryLimitBytes.Value)
|
||||
</MudChip>
|
||||
</MudItem>
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(_agent.DiskInventoryJson))
|
||||
{
|
||||
<MudItem xs="12" Class="mt-2">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Disques</MudText>
|
||||
@{
|
||||
var disks = ParseDiskJson(_agent.DiskInventoryJson);
|
||||
}
|
||||
@if (disks.Count > 0)
|
||||
{
|
||||
<MudTable Items="@disks" Dense="true" Hover="true" Elevation="0" Class="mt-1">
|
||||
<HeaderContent>
|
||||
<MudTh>Point de montage</MudTh>
|
||||
<MudTh>FS</MudTh>
|
||||
<MudTh>Taille</MudTh>
|
||||
<MudTh>Utilisé</MudTh>
|
||||
<MudTh>Type</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Point de montage">
|
||||
<MudText Typo="Typo.body2">@context.MountPoint</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="FS">
|
||||
<MudText Typo="Typo.body2">@context.FileSystem</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Taille">
|
||||
<MudText Typo="Typo.body2">@(context.TotalBytes.HasValue ? FormatBytes(context.TotalBytes.Value) : "-")</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Utilisé">
|
||||
<MudText Typo="Typo.body2">@(context.UsedBytes.HasValue ? FormatBytes(context.UsedBytes.Value) : "-")</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Type">
|
||||
<MudChip T="string" Size="Size.Small"
|
||||
Color="@(context.Type == "SSD" ? Color.Success : Color.Default)">
|
||||
@context.Type
|
||||
</MudChip>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mt-1">Aucun disque détecté</MudText>
|
||||
}
|
||||
</MudItem>
|
||||
}
|
||||
</MudGrid>
|
||||
</SectionCard>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudGrid Class="mt-4">
|
||||
@* ─── GPU Inventory ─── *@
|
||||
<MudItem xs="12" md="6">
|
||||
<SectionCard Title="GPU" Icon="@Icons.Material.Filled.Videocam" Elevation="2">
|
||||
@{
|
||||
var gpus = ParseGpuJson(_agent.GpuInventoryJson);
|
||||
}
|
||||
@if (gpus.Count > 0)
|
||||
{
|
||||
<MudTable Items="@gpus" Dense="true" Hover="true" Elevation="0">
|
||||
<HeaderContent>
|
||||
<MudTh>Modèle</MudTh>
|
||||
<MudTh>Backend</MudTh>
|
||||
<MudTh>VRAM</MudTh>
|
||||
<MudTh>Temp</MudTh>
|
||||
<MudTh>Utilisation</MudTh>
|
||||
<MudTh>Driver</MudTh>
|
||||
<MudTh>Encoder</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Modèle">
|
||||
<MudText Typo="Typo.body2" Class="font-weight-medium">@(context.Model ?? "-")</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Backend">
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Info">@(context.Backend ?? "-")</MudChip>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="VRAM">
|
||||
<MudText Typo="Typo.body2">@(context.VramBytes.HasValue ? FormatBytes(context.VramBytes.Value) : "-")</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Temp">
|
||||
<MudText Typo="Typo.body2">@(context.TemperatureCelsius.HasValue ? $"{context.TemperatureCelsius:F0}°C" : "-")</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Utilisation">
|
||||
<MudText Typo="Typo.body2">@(context.UtilizationPercent.HasValue ? $"{context.UtilizationPercent:F0}%" : "-")</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Driver">
|
||||
<MudText Typo="Typo.body2">@(context.DriverVersion ?? "-")</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Encoder">
|
||||
<MudText Typo="Typo.body2">@(context.EncoderSupport ?? "-")</MudText>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Aucun GPU détecté</MudText>
|
||||
}
|
||||
</SectionCard>
|
||||
</MudItem>
|
||||
|
||||
@* ─── Host & Container ─── *@
|
||||
<MudItem xs="12" md="6">
|
||||
<SectionCard Title="Système & Conteneur" Icon="@Icons.Material.Filled.Computer" Elevation="2">
|
||||
<MudGrid>
|
||||
@if (_agent.OsName is not null)
|
||||
{
|
||||
<MudItem xs="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">OS</MudText>
|
||||
<MudText Typo="Typo.body1">@_agent.OsName</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.KernelVersion is not null)
|
||||
{
|
||||
<MudItem xs="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Noyau</MudText>
|
||||
<MudText Typo="Typo.body1">@_agent.KernelVersion</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.Arch is not null)
|
||||
{
|
||||
<MudItem xs="6" Class="mt-2">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Architecture</MudText>
|
||||
<MudText Typo="Typo.body1">@_agent.Arch</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.UptimeMachineSeconds.HasValue)
|
||||
{
|
||||
<MudItem xs="6" Class="mt-2">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Uptime machine</MudText>
|
||||
<MudText Typo="Typo.body1">@FormatUptime(_agent.UptimeMachineSeconds.Value)</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.ContainerId is not null)
|
||||
{
|
||||
<MudItem xs="12" Class="mt-2">
|
||||
<MudDivider Class="mb-2" />
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Conteneur</MudText>
|
||||
<MudText Typo="Typo.body1">
|
||||
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Color="Color.Success" Size="Size.Small" Class="mr-1" />
|
||||
@(_agent.ContainerImage ?? "Conteneur Docker")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">ID: @_agent.ContainerId</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
@if (_agent.ContainerCpuLimit.HasValue)
|
||||
{
|
||||
<MudItem xs="6" Class="mt-2">
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Warning">
|
||||
CPU limite: @($"{_agent.ContainerCpuLimit.Value / 100.0:F1} cores")
|
||||
</MudChip>
|
||||
</MudItem>
|
||||
}
|
||||
</MudGrid>
|
||||
</SectionCard>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudGrid Class="mt-4">
|
||||
@* ─── Network Interfaces ─── *@
|
||||
<MudItem xs="12" md="6">
|
||||
<SectionCard Title="Réseau" Icon="@Icons.Material.Filled.Wifi" Elevation="2">
|
||||
@{
|
||||
var interfaces = ParseNetworkJson(_agent.NetworkInterfacesJson);
|
||||
}
|
||||
@if (interfaces.Count > 0)
|
||||
{
|
||||
<MudTable Items="@interfaces" Dense="true" Hover="true" Elevation="0">
|
||||
<HeaderContent>
|
||||
<MudTh>Interface</MudTh>
|
||||
<MudTh>Adresse IP</MudTh>
|
||||
<MudTh>MAC</MudTh>
|
||||
<MudTh>Débit</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Interface">
|
||||
<MudText Typo="Typo.body2" Class="font-weight-medium">@context.Name</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Adresse IP">
|
||||
<MudText Typo="Typo.body2">@(context.IpAddress ?? "-")</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="MAC">
|
||||
<MudText Typo="Typo.body2">@(context.MacAddress ?? "-")</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Débit">
|
||||
<MudText Typo="Typo.body2">@(context.SpeedMbps.HasValue ? $"{context.SpeedMbps} Mbps" : "-")</MudText>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Aucune interface réseau détectée</MudText>
|
||||
}
|
||||
</SectionCard>
|
||||
</MudItem>
|
||||
|
||||
@* ─── Temperature ─── *@
|
||||
<MudItem xs="12" md="6">
|
||||
<SectionCard Title="Températures" Icon="@Icons.Material.Filled.Thermostat" Elevation="2">
|
||||
@{
|
||||
var temps = ParseTemperatureJson(_agent.TemperatureJson);
|
||||
}
|
||||
@if (temps.Count > 0)
|
||||
{
|
||||
<MudTable Items="@temps" Dense="true" Hover="true" Elevation="0">
|
||||
<HeaderContent>
|
||||
<MudTh>Zone</MudTh>
|
||||
<MudTh>Température</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Zone">
|
||||
<MudText Typo="Typo.body2">@context.Zone</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Température">
|
||||
@{
|
||||
Color tempColor;
|
||||
if (context.TemperatureCelsius > 70)
|
||||
tempColor = Color.Error;
|
||||
else if (context.TemperatureCelsius > 50)
|
||||
tempColor = Color.Warning;
|
||||
else
|
||||
tempColor = Color.Default;
|
||||
}
|
||||
<MudText Typo="Typo.body2" Color="@tempColor">
|
||||
@($"{context.TemperatureCelsius:F1}°C")
|
||||
</MudText>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Aucune sonde de température détectée</MudText>
|
||||
}
|
||||
</SectionCard>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
@* ─── Agent Settings (globals hérités + overrides) ─── *@
|
||||
<SectionCard Title="Configuration"
|
||||
Icon="@Icons.Material.Filled.Tune"
|
||||
@@ -648,9 +1005,12 @@ else
|
||||
private async Task ToggleAutoRefresh(bool enabled)
|
||||
{
|
||||
_autoRefresh = enabled;
|
||||
_refreshCts?.Cancel();
|
||||
_refreshCts?.Dispose();
|
||||
_refreshCts = null;
|
||||
if (_refreshCts is not null)
|
||||
{
|
||||
await _refreshCts.CancelAsync();
|
||||
_refreshCts.Dispose();
|
||||
_refreshCts = null;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
@@ -681,12 +1041,15 @@ else
|
||||
_ => Color.Default
|
||||
};
|
||||
|
||||
public void Dispose()
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
_disposed = true;
|
||||
_refreshCts?.Cancel();
|
||||
_refreshCts?.Dispose();
|
||||
_refreshCts = null;
|
||||
if (_refreshCts is not null)
|
||||
{
|
||||
await _refreshCts.CancelAsync();
|
||||
_refreshCts.Dispose();
|
||||
_refreshCts = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Color GetStatusColor(string status) => status switch
|
||||
@@ -749,4 +1112,111 @@ else
|
||||
? p.ToUpperInvariant()
|
||||
: char.ToUpperInvariant(p[0]) + p[1..]));
|
||||
}
|
||||
|
||||
// ─── Inventory helpers ─────────────────────────────────────────
|
||||
|
||||
private static string FormatBytes(long bytes) => bytes switch
|
||||
{
|
||||
>= 1_073_741_824L => $"{bytes / 1_073_741_824.0:F1} Go",
|
||||
>= 1_048_576L => $"{bytes / 1_048_576.0:F1} Mo",
|
||||
>= 1024L => $"{bytes / 1024.0:F1} Ko",
|
||||
_ => $"{bytes} o"
|
||||
};
|
||||
|
||||
private static string FormatUptime(long seconds) => seconds switch
|
||||
{
|
||||
>= 86400 => $"{seconds / 86400}j {seconds % 86400 / 3600}h",
|
||||
>= 3600 => $"{seconds / 3600}h {seconds % 3600 / 60}m",
|
||||
>= 60 => $"{seconds / 60}m {seconds % 60}s",
|
||||
_ => $"{seconds}s"
|
||||
};
|
||||
|
||||
private static List<DiskDto> ParseDiskJson(string? json)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json)) return [];
|
||||
try
|
||||
{
|
||||
return System.Text.Json.JsonSerializer.Deserialize<List<DiskDto>>(json) ?? [];
|
||||
}
|
||||
catch { return []; }
|
||||
}
|
||||
|
||||
private static List<GpuDto> ParseGpuJson(string? json)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json)) return [];
|
||||
try
|
||||
{
|
||||
return System.Text.Json.JsonSerializer.Deserialize<List<GpuDto>>(json) ?? [];
|
||||
}
|
||||
catch { return []; }
|
||||
}
|
||||
|
||||
private static List<NetworkDto> ParseNetworkJson(string? json)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json)) return [];
|
||||
try
|
||||
{
|
||||
return System.Text.Json.JsonSerializer.Deserialize<List<NetworkDto>>(json) ?? [];
|
||||
}
|
||||
catch { return []; }
|
||||
}
|
||||
|
||||
private static List<TempDto> ParseTemperatureJson(string? json)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json)) return [];
|
||||
try
|
||||
{
|
||||
return System.Text.Json.JsonSerializer.Deserialize<List<TempDto>>(json) ?? [];
|
||||
}
|
||||
catch { return []; }
|
||||
}
|
||||
|
||||
// DTOs for JSON deserialization
|
||||
private sealed class DiskDto
|
||||
{
|
||||
public string MountPoint { get; init; } = "";
|
||||
public string FileSystem { get; init; } = "";
|
||||
public long? TotalBytes { get; init; } = null;
|
||||
public long? UsedBytes { get; init; } = null;
|
||||
public string Type { get; init; } = "Unknown";
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
private sealed class GpuDto
|
||||
{
|
||||
[JsonPropertyName("model")]
|
||||
public string? Model { get; init; }
|
||||
[JsonPropertyName("vramBytes")]
|
||||
public long? VramBytes { get; init; }
|
||||
[JsonPropertyName("driverVersion")]
|
||||
public string? DriverVersion { get; init; }
|
||||
[JsonPropertyName("temperatureCelsius")]
|
||||
public double? TemperatureCelsius { get; init; }
|
||||
[JsonPropertyName("utilizationPercent")]
|
||||
public double? UtilizationPercent { get; init; }
|
||||
[JsonPropertyName("backend")]
|
||||
public string? Backend { get; init; }
|
||||
[JsonPropertyName("encoderSupport")]
|
||||
public string? EncoderSupport { get; init; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
private sealed class NetworkDto
|
||||
{
|
||||
public string Name { get; init; } = "";
|
||||
[JsonPropertyName("ipAddress")]
|
||||
public string? IpAddress { get; init; }
|
||||
[JsonPropertyName("macAddress")]
|
||||
public string? MacAddress { get; init; }
|
||||
[JsonPropertyName("speedMbps")]
|
||||
public long? SpeedMbps { get; init; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
private sealed class TempDto
|
||||
{
|
||||
public string Zone { get; init; } = "";
|
||||
[JsonPropertyName("temperatureCelsius")]
|
||||
public double TemperatureCelsius { get; init; }
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@
|
||||
{
|
||||
<MudChip T="string" Size="Size.Small" Class="ml-3"
|
||||
Color="@(_testResult.Healthy == true ? Color.Success : Color.Error)" Variant="Variant.Outlined">
|
||||
@(_testResult.Healthy == true ? "Opérationnel" : _testResult.Configured == false ? "Non configuré" : "Injoignable")
|
||||
@GetStorageTestStatus()
|
||||
</MudChip>
|
||||
}
|
||||
</div>
|
||||
@@ -83,6 +83,13 @@
|
||||
private bool _testing;
|
||||
private StorageTestResult? _testResult;
|
||||
|
||||
private string GetStorageTestStatus()
|
||||
{
|
||||
if (_testResult?.Healthy is true) return "Opérationnel";
|
||||
if (_testResult?.Configured is false) return "Non configuré";
|
||||
return "Injoignable";
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||
@using Microsoft.JSInterop
|
||||
@using MudBlazor
|
||||
@using System.Text.Json.Serialization
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
@using Heimdall.Web
|
||||
|
||||
Reference in new issue
Block a user