1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-07 21:58:06 -05:00

Add instance uptime to API info response

This update includes the instance uptime in the API info response.
This commit is contained in:
Ayymoss 2024-09-04 13:55:20 +01:00 committed by RaidMax
parent a1a69242f7
commit 0a8bbf2997
2 changed files with 5 additions and 1 deletions

View File

@ -10,6 +10,7 @@ public class InfoResponse
public MetricSnapshot<int> TotalRecentClients { get; set; } public MetricSnapshot<int> TotalRecentClients { get; set; }
public MetricSnapshot<int?> MaxConcurrentClients { get; set; } public MetricSnapshot<int?> MaxConcurrentClients { get; set; }
public TimeSpan Uptime { get; set; }
} }
public class MetricSnapshot<T> public class MetricSnapshot<T>

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -30,6 +31,7 @@ public class Info : BaseController
var (totalClients, totalRecentClients) = var (totalClients, totalRecentClients) =
await _serverDataViewer.ClientCountsAsync(duration, game, token); await _serverDataViewer.ClientCountsAsync(duration, game, token);
var (maxConcurrent, maxConcurrentTime) = await _serverDataViewer.MaxConcurrentClientsAsync(overPeriod: duration, token: token); var (maxConcurrent, maxConcurrentTime) = await _serverDataViewer.MaxConcurrentClientsAsync(overPeriod: duration, token: token);
var uptime = DateTime.Now - Process.GetCurrentProcess().StartTime;
var response = new InfoResponse var response = new InfoResponse
{ {
TotalTrackedClients = totalClients, TotalTrackedClients = totalClients,
@ -46,7 +48,8 @@ public class Info : BaseController
Value = totalRecentClients, Value = totalRecentClients,
EndAt = DateTime.UtcNow, EndAt = DateTime.UtcNow,
StartAt = DateTime.UtcNow - duration StartAt = DateTime.UtcNow - duration
} },
Uptime = uptime,
}; };
return Json(response); return Json(response);