broken! Graph not showing
This commit is contained in:
@@ -215,7 +215,7 @@ public class MonitoringController : Controller
|
||||
|
||||
|
||||
// Durchschnittliche Werte Berechnen
|
||||
[HttpGet]
|
||||
[HttpGet("median")]
|
||||
public async Task<IActionResult> CalculateMedian(string Metric, int HoursToMonitor, int ServerId)
|
||||
{
|
||||
// Aktuelle Zeit - X Stunden = letzter Wert, der berücksichtigt werden soll
|
||||
@@ -230,4 +230,23 @@ public class MonitoringController : Controller
|
||||
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
[HttpPost("cpu-usage")]
|
||||
public async Task<IActionResult> GetCpuUsageData()
|
||||
{
|
||||
var oneDayAgo = DateTime.UtcNow.AddDays(-1);
|
||||
var data = await _context.Metrics
|
||||
.Where(m => m.Timestamp >= oneDayAgo)
|
||||
.OrderBy(m => m.Timestamp)
|
||||
.Select(m => new
|
||||
{
|
||||
// Hier die Formatierung anpassen
|
||||
// 'o' ist der Standard-Formatbezeichner für ISO 8601-Format mit Zeitzone
|
||||
Timestamp = m.Timestamp.ToUniversalTime().ToString("o"), // Wichtig: ToUniversalTime() für Konsistenz
|
||||
CpuUsage = m.CPU_Load
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return Ok(data);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user