sanitizemetrics eingeführt

This commit is contained in:
2025-10-01 12:52:45 +02:00
parent 5e2f9e4c3c
commit 36e16fbcf9

View File

@@ -55,26 +55,26 @@ public class MetricDto
public double GPU_Temp { get; set; } // deg C public double GPU_Temp { get; set; } // deg C
public double GPU_Vram_Size { get; set; } // GB public double GPU_Vram_Size { get; set; } // Bytes
public double GPU_Vram_Usage { get; set; } // % public double GPU_Vram_Usage { get; set; } // %
// RAM // RAM
public double RAM_Size { get; set; } // GB public double RAM_Size { get; set; } // Bytes
public double RAM_Load { get; set; } // % public double RAM_Load { get; set; } // %
// Disks // Disks
public double DISK_Size { get; set; } // GB public double DISK_Size { get; set; } // Bytes
public double DISK_Usage { get; set; } // % public double DISK_Usage { get; set; } // Bytes
public double DISK_Temp { get; set; } // deg C public double DISK_Temp { get; set; } // deg C (if available)
// Network // Network
public double NET_In { get; set; } // Bit public double NET_In { get; set; } // Bytes/s
public double NET_Out { get; set; } // Bit public double NET_Out { get; set; } // Bytes/s
} }
@@ -173,6 +173,7 @@ public class MonitoringController : Controller
if (server != null) if (server != null)
{ {
// neues Metric-Objekt erstellen
var NewMetric = new Metric var NewMetric = new Metric
{ {
Timestamp = DateTime.UtcNow, Timestamp = DateTime.UtcNow,
@@ -181,18 +182,19 @@ public class MonitoringController : Controller
CPU_Temp = dto.CPU_Temp, CPU_Temp = dto.CPU_Temp,
GPU_Load = dto.GPU_Load, GPU_Load = dto.GPU_Load,
GPU_Temp = dto.GPU_Temp, GPU_Temp = dto.GPU_Temp,
GPU_Vram_Size = dto.GPU_Vram_Size, GPU_Vram_Size = sanitizeByteInput(dto.GPU_Vram_Size),
GPU_Vram_Usage = dto.GPU_Vram_Usage, GPU_Vram_Usage = dto.GPU_Vram_Usage,
RAM_Load = sanitizeByteInput(dto.RAM_Load), RAM_Load = sanitizeByteInput(dto.RAM_Load),
RAM_Size = dto.RAM_Size, RAM_Size = sanitizeByteInput(dto.RAM_Size),
DISK_Size = dto.RAM_Size, DISK_Size = sanitizeByteInput(dto.DISK_Size),
DISK_Usage = dto.DISK_Usage, DISK_Usage = sanitizeByteInput(dto.DISK_Usage),
DISK_Temp = dto.DISK_Temp, DISK_Temp = dto.DISK_Temp,
NET_In = dto.NET_In, NET_In = sanitizeByteInput(dto.NET_In),
NET_Out = dto.NET_Out NET_Out = sanitizeByteInput(dto.NET_Out)
}; };
try try
{ {
// Metric Objekt in Datenbank einfügen
_context.Metrics.Add(NewMetric); _context.Metrics.Add(NewMetric);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync();