Add Metrics tab with historical server utilization and map capacity
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user