feat(agent): détection GPU + heartbeat étendu + badges Admin UI (#160)

This commit is contained in:
Arnaud Dartois authored and Arnaud Dartois committed 2026-08-26 23:52:16 +02:00
1 parent ba5c1776ae
commit 6eae4eea2f
20 files changed
+2767 -11

No files matched your search

Submodule .worktrees/t_0fbbf8b9 added at f7e6b0cec3.
Submodule .worktrees/wt-broker added at 844934b1cb.
+1
Submodule .worktrees/wt-gpu added at 0d9315f6c8.
Submodule .worktrees/wt-scheduler added at 80644fb5bc.
+1 -2
View File
@@ -84,14 +84,13 @@ builder.Services.AddSingleton<AgentState>(sp =>
});
builder.Services.AddSingleton<SystemMetricsProvider>();
// Inventory providers (grouped under InventoryProviders to reduce constructor parameter count)
builder.Services.AddSingleton<CpuInfoProvider>();
builder.Services.AddSingleton<DiskInventoryProvider>();
builder.Services.AddSingleton<HostInfoProvider>();
builder.Services.AddSingleton<ContainerInfoProvider>();
builder.Services.AddSingleton<InventoryProviders>();
builder.Services.AddSingleton<GpuDetectorService>();
builder.Services.AddSingleton<NetworkCameraScanner>();
builder.Services.AddSingleton<HomeKitMdnsProbe>();
builder.Services.AddSingleton<ICameraDatabase, SqliteCameraDatabase>();
@@ -31,6 +31,7 @@ public class AgentRegistrationService : BackgroundService
private readonly AgentOptions _options;
private readonly SystemMetricsProvider _metrics;
private readonly InventoryProviders _providers;
private readonly GpuDetectorService _gpu;
private readonly Logging.LogBufferService _buffer;
private HttpClient? _client;
@@ -45,6 +46,7 @@ public class AgentRegistrationService : BackgroundService
IOptions<AgentOptions> options,
SystemMetricsProvider metrics,
InventoryProviders providers,
GpuDetectorService gpu,
Logging.LogBufferService buffer,
ILogger<AgentRegistrationService> logger)
{
@@ -53,6 +55,7 @@ public class AgentRegistrationService : BackgroundService
_options = options.Value;
_metrics = metrics;
_providers = providers;
_gpu = gpu;
_buffer = buffer;
_logger = logger;
}
@@ -76,11 +79,22 @@ public class AgentRegistrationService : BackgroundService
try
{
var metrics = _metrics.Collect();
_gpu.RefreshMetrics();
var gpuInfo = _gpu.GetInfo();
var totalMemoryMb = metrics.TotalMemoryBytes is { } mem ? mem / (1024 * 1024) : (long?)null;
var request = new HeartbeatRequest(_state.PublicIp, IsOffline: true,
HasGpu: gpuInfo.GpuType != Domain.Enums.GpuAcceleration.None,
CpuCores: Environment.ProcessorCount,
MemoryMb: totalMemoryMb,
CpuUsagePercent: metrics.CpuUsagePercent,
MemoryUsageBytes: metrics.MemoryUsageBytes,
DiskUsagePercent: metrics.DiskUsagePercent,
UptimeSeconds: metrics.UptimeSeconds);
UptimeSeconds: metrics.UptimeSeconds,
GpuType: gpuInfo.GpuType != Domain.Enums.GpuAcceleration.None ? gpuInfo.GpuType.ToString() : null,
GpuName: gpuInfo.GpuName,
VramMb: gpuInfo.VramMb,
GpuLoadPercent: gpuInfo.GpuLoadPercent,
VramUsageBytes: gpuInfo.VramUsageBytes);
await _client!.PostAsJsonAsync(
$"api/agents/{_state.AgentId}/heartbeat",
request, CancellationToken.None);
@@ -222,8 +236,22 @@ public class AgentRegistrationService : BackgroundService
}
}
private HeartbeatRequest BuildHeartbeatRequest(SystemMetrics metrics, InventorySnapshot? inventory) => new(
private HeartbeatRequest BuildHeartbeatRequest(SystemMetrics metrics, InventorySnapshot? inventory)
{
_gpu.RefreshMetrics();
var gpuInfo = _gpu.GetInfo();
var totalMemoryMb = metrics.TotalMemoryBytes is { } mem ? mem / (1024 * 1024) : (long?)null;
return new HeartbeatRequest(
_state.PublicIp,
HasGpu: gpuInfo.GpuType != Domain.Enums.GpuAcceleration.None,
CpuCores: Environment.ProcessorCount,
MemoryMb: totalMemoryMb,
GpuType: gpuInfo.GpuType != Domain.Enums.GpuAcceleration.None ? gpuInfo.GpuType.ToString() : null,
GpuName: gpuInfo.GpuName,
VramMb: gpuInfo.VramMb,
GpuLoadPercent: gpuInfo.GpuLoadPercent,
VramUsageBytes: gpuInfo.VramUsageBytes,
CpuUsagePercent: metrics.CpuUsagePercent,
MemoryUsageBytes: metrics.MemoryUsageBytes,
DiskUsagePercent: metrics.DiskUsagePercent,
@@ -254,6 +282,7 @@ public class AgentRegistrationService : BackgroundService
ContainerImage: inventory?.Container?.ContainerImage,
NetworkInterfacesJson: inventory?.NetworkJson,
TemperatureJson: inventory?.TemperatureJson);
}
private InventorySnapshot? CollectInventoryIfNeeded()
{
@@ -0,0 +1,294 @@
using System.Diagnostics;
using System.Text.RegularExpressions;
using Heimdall.Domain.Enums;
using Microsoft.Extensions.Logging;
namespace Heimdall.Agent.Services;
/// <summary>
/// Detects GPU hardware at startup and provides live GPU metrics (load, VRAM).
/// Supports NVIDIA (nvidia-smi), AMD (rocm-smi), Intel QuickSync, and VAAPI.
/// </summary>
public sealed partial class GpuDetectorService
{
private readonly ILogger<GpuDetectorService> _logger;
private GpuInfo _cachedInfo = new();
public GpuDetectorService(ILogger<GpuDetectorService> logger)
{
_logger = logger;
DetectGpu();
}
/// <summary>Returns the detected GPU info (static + live metrics).</summary>
public GpuInfo GetInfo() => _cachedInfo;
/// <summary>Refreshes live GPU metrics (load %, VRAM usage). Call each heartbeat.</summary>
public void RefreshMetrics()
{
if (_cachedInfo.GpuType == GpuAcceleration.None)
return;
try
{
switch (_cachedInfo.GpuType)
{
case GpuAcceleration.NvidiaCuda:
RefreshNvidiaMetrics();
break;
case GpuAcceleration.AmdRocm:
RefreshAmdMetrics();
break;
// Intel/VAAPI: no load/VRAM metrics available via CLI
}
}
catch (Exception ex)
{
_logger.LogDebug(ex, "Failed to refresh GPU metrics");
}
}
private void DetectGpu()
{
// Try NVIDIA first (most common for AI workloads)
if (TryDetectNvidia())
return;
// Then AMD ROCm
if (TryDetectAmd())
return;
// Then Intel QuickSync / VAAPI
if (TryDetectIntel())
return;
// Fallback: check for VAAPI device
if (TryDetectVaapi())
return;
_logger.LogInformation("No GPU detected — running in CPU-only mode");
}
private bool TryDetectNvidia()
{
try
{
var output = RunCommand("nvidia-smi",
"--query-gpu=name,memory.total,memory.used,utilization.gpu --format=csv,noheader,nounits");
if (string.IsNullOrWhiteSpace(output))
return false;
// nvidia-smi returns: "NVIDIA GeForce RTX 3080, 10240, 1234, 67"
var parts = output.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
if (parts.Length < 4)
return false;
var name = parts[0];
if (!long.TryParse(parts[1], out var vramTotalMb))
return false;
var vramUsedMb = long.TryParse(parts[2], out var parsedVram) ? parsedVram : 0;
var loadPercent = double.TryParse(parts[3], out var parsedLoad) ? parsedLoad : 0;
_cachedInfo = new GpuInfo
{
GpuType = GpuAcceleration.NvidiaCuda,
GpuName = name,
VramMb = vramTotalMb,
GpuLoadPercent = loadPercent,
VramUsageBytes = vramUsedMb * 1024 * 1024
};
_logger.LogInformation("NVIDIA GPU detected: {Name}, {Vram} MB VRAM", name, vramTotalMb);
return true;
}
catch (Exception ex)
{
_logger.LogDebug(ex, "nvidia-smi detection failed");
return false;
}
}
private bool TryDetectAmd()
{
try
{
var output = RunCommand("rocm-smi", "--showuse --json");
if (string.IsNullOrWhiteSpace(output))
return false;
// Simple JSON parse without external deps — look for key patterns
var nameMatch = Regex.Match(output, @"""card[0-9]""\s*:\s*\{[^}]*""Card name""\s*:\s*""([^""]+)""");
var vramMatch = Regex.Match(output, @"""VRAM Total Memory \(MiB\)""\s*:\s*""?(\d+)""?");
if (!nameMatch.Success)
return false;
var name = nameMatch.Groups[1].Value;
var vramMb = long.TryParse(vramMatch.Groups[1].Value, out var parsedVram) ? parsedVram : 0;
_cachedInfo = new GpuInfo
{
GpuType = GpuAcceleration.AmdRocm,
GpuName = name,
VramMb = vramMb > 0 ? vramMb : null
};
_logger.LogInformation("AMD GPU detected: {Name}", name);
return true;
}
catch (Exception ex)
{
_logger.LogDebug(ex, "rocm-smi detection failed");
return false;
}
}
private bool TryDetectIntel()
{
try
{
if (!OperatingSystem.IsLinux())
return false;
// Check lspci for Intel VGA/3D controller
var output = RunCommand("lspci", "");
if (string.IsNullOrWhiteSpace(output))
return false;
var intelLines = output.Split('\n')
.Where(l => l.Contains("Intel", StringComparison.OrdinalIgnoreCase) &&
(l.Contains("VGA", StringComparison.OrdinalIgnoreCase) ||
l.Contains("3D", StringComparison.OrdinalIgnoreCase)))
.ToList();
if (intelLines.Count == 0)
return false;
// Extract device name from lspci line: "00:02.0 VGA compatible controller: Intel Corporation ..."
var name = intelLines[0];
var colonIdx = name.IndexOf(':');
if (colonIdx > 0)
{
var afterColon = name[(colonIdx + 1)..];
var nameColonIdx = afterColon.IndexOf(':');
if (nameColonIdx > 0)
name = afterColon[(nameColonIdx + 1)..].Trim();
}
_cachedInfo = new GpuInfo
{
GpuType = GpuAcceleration.IntelQuickSync,
GpuName = name
};
_logger.LogInformation("Intel GPU detected: {Name}", name);
return true;
}
catch (Exception ex)
{
_logger.LogDebug(ex, "Intel GPU detection failed");
return false;
}
}
private bool TryDetectVaapi()
{
try
{
if (!OperatingSystem.IsLinux())
return false;
// Check for /dev/dri/renderD128 (VAAPI render node)
if (!File.Exists("/dev/dri/renderD128"))
return false;
_cachedInfo = new GpuInfo
{
GpuType = GpuAcceleration.Vaapi,
GpuName = "VAAPI device"
};
_logger.LogInformation("VAAPI device detected at /dev/dri/renderD128");
return true;
}
catch
{
return false;
}
}
private void RefreshNvidiaMetrics()
{
var output = RunCommand("nvidia-smi",
"--query-gpu=utilization.gpu,memory.used --format=csv,noheader,nounits");
if (string.IsNullOrWhiteSpace(output))
return;
var parts = output.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
if (parts.Length >= 2)
{
var load = double.TryParse(parts[0], out var parsedLoad) ? parsedLoad : (double?)null;
var vramUsedMb = long.TryParse(parts[1], out var parsedVram) ? parsedVram : (long?)null;
if (load.HasValue || vramUsedMb.HasValue)
{
_cachedInfo = _cachedInfo with
{
GpuLoadPercent = load,
VramUsageBytes = vramUsedMb is { } v ? v * 1024 * 1024 : null
};
}
}
}
private void RefreshAmdMetrics()
{
var output = RunCommand("rocm-smi", "--showuse --json");
if (string.IsNullOrWhiteSpace(output))
return;
var loadMatch = Regex.Match(output, @"""GPU use \(%\)""\s*:\s*""?([0-9.]+)""?");
if (loadMatch.Success && double.TryParse(loadMatch.Groups[1].Value, out var load))
{
_cachedInfo = _cachedInfo with { GpuLoadPercent = load };
}
}
private static string? RunCommand(string command, string arguments)
{
try
{
using var process = Process.Start(new ProcessStartInfo
{
FileName = command,
Arguments = arguments,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
});
if (process is null)
return null;
var output = process.StandardOutput.ReadToEnd();
process.WaitForExit(3000);
return process.ExitCode == 0 ? output?.Trim() : null;
}
catch
{
return null;
}
}
}
/// <summary>GPU information — static hardware details + live metrics.</summary>
public sealed record GpuInfo
{
public GpuAcceleration GpuType { get; init; } = GpuAcceleration.None;
public string? GpuName { get; init; }
public long? VramMb { get; init; }
public double? GpuLoadPercent { get; init; }
public long? VramUsageBytes { get; init; }
}
@@ -13,6 +13,10 @@ public record HeartbeatCommand(
int? CpuCores,
int? MemoryMb,
GpuAcceleration? GpuType,
string? GpuName = null,
long? VramMb = null,
double? GpuLoadPercent = null,
long? VramUsageBytes = null,
bool IsOffline = false,
double? CpuUsagePercent = null,
long? MemoryUsageBytes = null,
@@ -14,6 +14,10 @@ public record AgentHeartbeatRequest(
int? CpuCores,
long? MemoryMb,
string? GpuType,
string? GpuName = null,
long? VramMb = null,
double? GpuLoadPercent = null,
long? VramUsageBytes = null,
bool IsOffline = false,
double? CpuUsagePercent = null,
long? MemoryUsageBytes = null,
@@ -72,6 +76,10 @@ public record AgentResponse(
int CpuCores,
long MemoryMb,
string GpuType,
string? GpuName,
long? VramMb,
double? GpuLoadPercent,
long? VramUsageBytes,
DateTime CreatedAt,
double? CpuUsagePercent = null,
long? MemoryUsageBytes = null,
+16
View File
@@ -24,12 +24,16 @@ public class Agent : Entity<Guid>, IAuditableEntity, ISoftDeletable
public int CpuCores { get; private set; }
public long MemoryMb { get; private set; }
public GpuAcceleration GpuType { get; private set; } = GpuAcceleration.None;
public string? GpuName { get; private set; }
public long? VramMb { get; private set; }
// Live metrics (sent with each heartbeat)
public double? CpuUsagePercent { get; private set; }
public long? MemoryUsageBytes { get; private set; }
public double? DiskUsagePercent { get; private set; }
public long? UptimeSeconds { get; private set; }
public double? GpuLoadPercent { get; private set; }
public long? VramUsageBytes { get; private set; }
// ─── CPU inventory ────────────────────────────────────────────
public string? CpuVendor { get; private set; }
@@ -142,6 +146,18 @@ public class Agent : Entity<Guid>, IAuditableEntity, ISoftDeletable
GpuType = gpuType;
}
/// <summary>
/// Updates GPU-specific details reported by the agent (name, VRAM, load).
/// Called alongside capabilities when the agent detects GPU hardware.
/// </summary>
public void UpdateGpuInfo(string? gpuName, long? vramMb, double? gpuLoadPercent, long? vramUsageBytes)
{
GpuName = gpuName;
VramMb = vramMb;
GpuLoadPercent = gpuLoadPercent;
VramUsageBytes = vramUsageBytes;
}
public void SoftDelete()
{
IsDeleted = true;
+2 -1
View File
@@ -5,5 +5,6 @@ public enum GpuAcceleration
None = 0,
NvidiaCuda = 1,
IntelQuickSync = 2,
Vaapi = 3
Vaapi = 3,
AmdRocm = 4
}
@@ -49,6 +49,16 @@ public class AgentConfiguration : IEntityTypeConfiguration<Agent>
.HasMaxLength(20)
.IsUnicode(false);
builder.Property(a => a.GpuName)
.HasMaxLength(200)
.IsUnicode(false);
builder.Property(a => a.VramMb);
builder.Property(a => a.GpuLoadPercent);
builder.Property(a => a.VramUsageBytes);
builder.Property(a => a.CreatedAt)
.HasDefaultValueSql("NOW()");
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,60 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Heimdall.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddGpuDetailsToAgent : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<double>(
name: "GpuLoadPercent",
table: "agents",
type: "double precision",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "GpuName",
table: "agents",
type: "character varying(200)",
unicode: false,
maxLength: 200,
nullable: true);
migrationBuilder.AddColumn<long>(
name: "VramMb",
table: "agents",
type: "bigint",
nullable: true);
migrationBuilder.AddColumn<long>(
name: "VramUsageBytes",
table: "agents",
type: "bigint",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "GpuLoadPercent",
table: "agents");
migrationBuilder.DropColumn(
name: "GpuName",
table: "agents");
migrationBuilder.DropColumn(
name: "VramMb",
table: "agents");
migrationBuilder.DropColumn(
name: "VramUsageBytes",
table: "agents");
}
}
}
@@ -17,7 +17,7 @@ namespace Heimdall.Infrastructure.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.8")
.HasAnnotation("ProductVersion", "10.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -94,6 +94,14 @@ namespace Heimdall.Infrastructure.Migrations
b.Property<string>("GpuInventoryJson")
.HasColumnType("text");
b.Property<double?>("GpuLoadPercent")
.HasColumnType("double precision");
b.Property<string>("GpuName")
.HasMaxLength(200)
.IsUnicode(false)
.HasColumnType("character varying(200)");
b.Property<string>("GpuType")
.IsRequired()
.HasMaxLength(20)
@@ -191,6 +199,12 @@ namespace Heimdall.Infrastructure.Migrations
.IsUnicode(false)
.HasColumnType("character varying(50)");
b.Property<long?>("VramMb")
.HasColumnType("bigint");
b.Property<long?>("VramUsageBytes")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("LastHeartbeat")
+74 -1
View File
@@ -6,7 +6,7 @@
<MudPaper Elevation="1" Class="pa-4 hmd-tile" Style="border-radius: var(--hmd-radius-md); height: 100%; display:flex; flex-direction:column;">
@* ─── En-tête : nom + statut ─── *@
<div class="d-flex align-center mb-3">
<MudIcon Icon="@(Agent.Status == "Online" ? Icons.Material.Filled.Memory : Icons.Material.Filled.Memory)" Size="Size.Small" Class="mr-2" Color="Color.Secondary" />
<MudIcon Icon="@Icons.Material.Filled.Memory" Size="Size.Small" Class="mr-2" Color="Color.Secondary" />
<MudLink Href="@($"/agents/{Agent.Id}")" Typo="Typo.subtitle1" Class="font-weight-medium text-truncate" style="flex:1;">
@Agent.Name
</MudLink>
@@ -19,6 +19,23 @@
@if (!string.IsNullOrEmpty(Agent.PublicIp)) { <span> · @Agent.PublicIp</span> }
</MudText>
@* ─── GPU Badge ─── *@
@if (Agent.HasGpu && Agent.GpuType != "None")
{
<div class="d-flex align-center mb-3" style="gap: 6px;">
<MudChip T="string" Size="Size.Small" Color="Color.Info" Variant="Variant.Outlined"
Icon="@Icons.Material.Filled.Memory">
@GetGpuLabel(Agent.GpuType)
</MudChip>
@if (!string.IsNullOrEmpty(Agent.GpuName))
{
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="text-truncate" Style="max-width:160px;">
@Agent.GpuName
</MudText>
}
</div>
}
@if (Agent.Status != "Online")
{
<div class="d-flex align-center justify-center flex-column" style="flex:1; min-height: 120px;">
@@ -65,6 +82,36 @@
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mt-1">
<MudIcon Icon="@Icons.Material.Filled.Schedule" Size="Size.Small" Class="mr-1" /> Uptime : @FormatUptime()
</MudText>
@* GPU Live Metrics *@
@if (Agent.HasGpu && Agent.GpuType != "None" && Agent.GpuLoadPercent.HasValue)
{
<div>
<div class="d-flex justify-space-between">
<MudText Typo="Typo.caption">GPU</MudText>
<MudText Typo="Typo.caption" Color="@(Agent.GpuLoadPercent > 95 ? Color.Error : Agent.GpuLoadPercent > 90 ? Color.Warning : Color.Success)">
@(Agent.GpuLoadPercent?.ToString("F0") ?? "—")%
</MudText>
</div>
<MudProgressLinear Value="@(Agent.GpuLoadPercent ?? 0)"
Color="@(Agent.GpuLoadPercent > 95 ? Color.Error : Agent.GpuLoadPercent > 90 ? Color.Warning : Color.Success)"
Rounded="true" Size="Size.Small" />
</div>
}
@if (Agent.HasGpu && Agent.VramMb.HasValue && Agent.VramMb > 0)
{
<div>
<div class="d-flex justify-space-between">
<MudText Typo="Typo.caption">VRAM</MudText>
<MudText Typo="Typo.caption" Color="Color.Secondary">
@FormatVram()
</MudText>
</div>
<MudProgressLinear Value="@(VramPercent ?? 0)"
Color="@(VramPercent > 95 ? Color.Error : VramPercent > 90 ? Color.Warning : Color.Info)"
Rounded="true" Size="Size.Small" />
</div>
}
</div>
}
</MudPaper>
@@ -75,6 +122,16 @@
private double? CpuPercent => Agent.CpuUsagePercent is { } c ? Math.Clamp(c, 0, 100) : null;
private double? DiskPercent => Agent.DiskUsagePercent is { } d ? Math.Clamp(d, 0, 100) : null;
private double? VramPercent
{
get
{
if (Agent.VramMb is not { } total || total <= 0) return null;
var usedMb = Agent.VramUsageBytes is { } b ? b / 1024.0 / 1024.0 : 0;
return Math.Clamp(usedMb / total * 100, 0, 100);
}
}
private double? MemoryPercent
{
get
@@ -111,6 +168,22 @@
private static string FormatPercent(double? v) => v is { } p ? $"{p:F0}%" : "—";
private string FormatVram()
{
var usedMb = Agent.VramUsageBytes is { } b ? b / 1024.0 / 1024.0 : 0;
var totalMb = Agent.VramMb ?? 0;
return $"{usedMb:F0}/{totalMb} MB";
}
private static string GetGpuLabel(string gpuType) => gpuType switch
{
"NvidiaCuda" => "NVIDIA CUDA",
"AmdRocm" => "AMD ROCm",
"IntelQuickSync" => "Intel QSV",
"Vaapi" => "VAAPI",
_ => gpuType
};
private static Color GetMetricColor(double? v) => v switch
{
> 95 => Color.Error,
@@ -67,6 +67,10 @@ public class AgentsController : ControllerBase
request.CpuCores,
(int?)request.MemoryMb,
gpuType,
request.GpuName,
request.VramMb,
request.GpuLoadPercent,
request.VramUsageBytes,
request.IsOffline,
request.CpuUsagePercent,
request.MemoryUsageBytes,
@@ -846,6 +846,10 @@ public class AgentItem
public int CpuCores { get; set; }
public long MemoryMb { get; set; }
public string GpuType { get; set; } = "None";
public string? GpuName { get; set; }
public long? VramMb { get; set; }
public double? GpuLoadPercent { get; set; }
public long? VramUsageBytes { get; set; }
public DateTime CreatedAt { get; set; }
public double? CpuUsagePercent { get; set; }
public long? MemoryUsageBytes { get; set; }
@@ -278,6 +278,7 @@ public class AgentRegistrationServiceTests : IDisposable
Options.Create(_options),
_metrics,
providers,
new GpuDetectorService(NullLogger<GpuDetectorService>.Instance),
new Logging.LogBufferService(),
NullLogger<AgentRegistrationService>.Instance);
}
@@ -91,8 +91,10 @@ public class HeartbeatRequestTests
[Fact]
public void Equality_SameValues_AreEqual()
{
var a = new HeartbeatRequest("1.2.3.4", true, 50.0, 1024, 30.0, 3600);
var b = new HeartbeatRequest("1.2.3.4", true, 50.0, 1024, 30.0, 3600);
var a = new HeartbeatRequest("1.2.3.4", IsOffline: true, HasGpu: true, CpuCores: 4, MemoryMb: 8192,
CpuUsagePercent: 50.0, MemoryUsageBytes: 1024, DiskUsagePercent: 30.0, UptimeSeconds: 3600);
var b = new HeartbeatRequest("1.2.3.4", IsOffline: true, HasGpu: true, CpuCores: 4, MemoryMb: 8192,
CpuUsagePercent: 50.0, MemoryUsageBytes: 1024, DiskUsagePercent: 30.0, UptimeSeconds: 3600);
(a == b).ShouldBeTrue();
a.Equals(b).ShouldBeTrue();
@@ -120,8 +122,10 @@ public class HeartbeatRequestTests
[Fact]
public void GetHashCode_SameValues_AreEqual()
{
var a = new HeartbeatRequest("1.2.3.4", true, 50.0, 1024, 30.0, 3600);
var b = new HeartbeatRequest("1.2.3.4", true, 50.0, 1024, 30.0, 3600);
var a = new HeartbeatRequest("1.2.3.4", IsOffline: true, HasGpu: true, CpuCores: 4, MemoryMb: 8192,
CpuUsagePercent: 50.0, MemoryUsageBytes: 1024, DiskUsagePercent: 30.0, UptimeSeconds: 3600);
var b = new HeartbeatRequest("1.2.3.4", IsOffline: true, HasGpu: true, CpuCores: 4, MemoryMb: 8192,
CpuUsagePercent: 50.0, MemoryUsageBytes: 1024, DiskUsagePercent: 30.0, UptimeSeconds: 3600);
a.GetHashCode().ShouldBe(b.GetHashCode());
}