Add Metrics tab with historical server utilization and map capacity

This commit is contained in:
2026-09-20 21:58:08 -04:00
parent 3c8b5b2e40
commit 3a63e6d3ce
9 changed files with 304 additions and 4 deletions
+7
View File
@@ -310,6 +310,7 @@ export async function rconGetPlayerCount(server: string): Promise<number | null>
export interface RconStatus {
players: number;
capacity?: number | null;
map: string | null;
gametype: string | null;
roster: RconPlayer[];
@@ -437,6 +438,7 @@ export async function rconStatusResult(server: string): Promise<RconStatusResult
// Prefer statusResponse `\info\` line values when present, fall
// back to print-body `key: value` header lines otherwise.
players,
capacity: positiveCapacity(info.sv_maxclients ?? info.sv_maxClients ?? header.sv_maxclients ?? header.sv_maxClients),
map: info.mapname ?? info.sv_mapname ?? header.map ?? header.mapname ?? header.sv_mapname ?? null,
gametype: info.g_gametype ?? header.g_gametype ?? header.gametype ?? null,
roster: parsePlayerRoster(text)
@@ -444,3 +446,8 @@ export async function rconStatusResult(server: string): Promise<RconStatusResult
rawReply: formatRawReply(send.buf)
};
}
function positiveCapacity(value: string | undefined): number | null {
const count = Number(value);
return Number.isInteger(count) && count > 0 ? count : null;
}