Graphen fertig
This commit is contained in:
@@ -232,17 +232,15 @@ public class MonitoringController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("cpu-usage")]
|
||||
public async Task<IActionResult> GetCpuUsageData()
|
||||
public async Task<IActionResult> GetCpuUsageData(int serverId)
|
||||
{
|
||||
var oneDayAgo = DateTime.UtcNow.AddDays(-1);
|
||||
var data = await _context.Metrics
|
||||
.Where(m => m.Timestamp >= oneDayAgo)
|
||||
.Where(m => m.Timestamp >= oneDayAgo && m.ServerId == serverId)
|
||||
.OrderBy(m => m.Timestamp)
|
||||
.Select(m => new
|
||||
{
|
||||
// Hier die Formatierung anpassen
|
||||
// 'o' ist der Standard-Formatbezeichner für ISO 8601-Format mit Zeitzone
|
||||
label = m.Timestamp.ToUniversalTime().ToString("o"), // Wichtig: ToUniversalTime() für Konsistenz
|
||||
label = m.Timestamp.ToUniversalTime().ToString("o"),
|
||||
data = m.CPU_Load
|
||||
})
|
||||
.ToListAsync();
|
||||
@@ -251,17 +249,15 @@ public class MonitoringController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("ram-usage")]
|
||||
public async Task<IActionResult> GetRamUsageData()
|
||||
public async Task<IActionResult> GetRamUsageData(int serverId)
|
||||
{
|
||||
var oneDayAgo = DateTime.UtcNow.AddDays(-1);
|
||||
var data = await _context.Metrics
|
||||
.Where(m => m.Timestamp >= oneDayAgo)
|
||||
.Where(m => m.Timestamp >= oneDayAgo && m.ServerId == serverId)
|
||||
.OrderBy(m => m.Timestamp)
|
||||
.Select(m => new
|
||||
{
|
||||
// Hier die Formatierung anpassen
|
||||
// 'o' ist der Standard-Formatbezeichner für ISO 8601-Format mit Zeitzone
|
||||
label = m.Timestamp.ToUniversalTime().ToString("o"), // Wichtig: ToUniversalTime() für Konsistenz
|
||||
label = m.Timestamp.ToUniversalTime().ToString("o"),
|
||||
data = m.RAM_Load
|
||||
})
|
||||
.ToListAsync();
|
||||
@@ -270,18 +266,16 @@ public class MonitoringController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("gpu-usage")]
|
||||
public async Task<IActionResult> GetGpuUsageData()
|
||||
public async Task<IActionResult> GetGpuUsageData(int serverId)
|
||||
{
|
||||
var oneDayAgo = DateTime.UtcNow.AddDays(-1);
|
||||
var data = await _context.Metrics
|
||||
.Where(m => m.Timestamp >= oneDayAgo)
|
||||
.Where(m => m.Timestamp >= oneDayAgo && m.ServerId == serverId)
|
||||
.OrderBy(m => m.Timestamp)
|
||||
.Select(m => new
|
||||
{
|
||||
// Hier die Formatierung anpassen
|
||||
// 'o' ist der Standard-Formatbezeichner für ISO 8601-Format mit Zeitzone
|
||||
label = m.Timestamp.ToUniversalTime().ToString("o"), // Wichtig: ToUniversalTime() für Konsistenz
|
||||
data = m.RAM_Load
|
||||
label = m.Timestamp.ToUniversalTime().ToString("o"),
|
||||
data = m.GPU_Load
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
|
Reference in New Issue
Block a user