Let each kind of game server alert be switched off

Three tick boxes on the Fragnet integration: do not alert about disk space,
memory or backups. The page still shows the figures (a switched-off bar is blue
and the backups tile says not judged); /metrics is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-08 22:36:54 +01:00
1 parent 4a7b1494c8
commit 1ef686d1ba
8 files changed
+58 -15

No files matched your search

+9 -3
View File
@@ -135,8 +135,13 @@ export interface FragnetOptions {
fullPercent: number;
/** Names (lower case) of the servers whose backups are not judged. */
ignoreBackups: string[];
/** Which kinds of alert are raised at all: each can be switched off in the integration's settings (everything is still shown on the page). */
alerts: { backups: boolean; disk: boolean; memory: boolean };
}
/** A checkbox as the settings keep it: true, or the text "true". */
const ticked = (v: unknown): boolean => v === true || v === "true";
const positive = (v: unknown): number | null => {
const n = typeof v === "number" ? v : typeof v === "string" && v.trim() !== "" ? Number(v.trim().replace(",", ".")) : NaN;
return Number.isFinite(n) && n >= 0 ? n : null;
@@ -150,6 +155,7 @@ export function optionsOf(config: Record<string, unknown> | null | undefined): F
backupDays: days === null ? DEFAULT_BACKUP_DAYS : days,
fullPercent: percent === null || percent < 1 ? DEFAULT_FULL_PERCENT : Math.min(100, percent),
ignoreBackups: ignore.split(/[,\n]/).map((s) => s.trim().toLowerCase()).filter(Boolean),
alerts: { backups: !ticked(config?.muteBackups), disk: !ticked(config?.muteDisk), memory: !ticked(config?.muteMemory) },
};
}
@@ -191,7 +197,7 @@ export function fragnetProblems(id: number, name: string, servers: StoredServer[
for (const s of [...servers].sort((a, b) => a.name.localeCompare(b.name))) {
// A server being installed or suspended is in no state to judge.
if (s.suspended || s.installing) continue;
if (options.backupDays > 0 && mayHaveBackups(s) && !options.ignoreBackups.includes(s.name.toLowerCase())) {
if (options.alerts.backups && options.backupDays > 0 && mayHaveBackups(s) && !options.ignoreBackups.includes(s.name.toLowerCase())) {
const newest = newestBackup(s);
if (newest !== null) {
const window = options.backupDays * DAY;
@@ -207,7 +213,7 @@ export function fragnetProblems(id: number, name: string, servers: StoredServer[
}
}
}
if (s.usage !== null && s.diskLimitMb !== null && s.diskLimitMb > 0) {
if (options.alerts.disk && s.usage !== null && s.diskLimitMb !== null && s.diskLimitMb > 0) {
const share = s.usage.diskBytes / (s.diskLimitMb * 1024 ** 2);
if (share >= limit) {
out.push({
@@ -218,7 +224,7 @@ export function fragnetProblems(id: number, name: string, servers: StoredServer[
});
}
}
if (s.state === "running" && s.usage !== null && s.memoryLimitMb !== null && s.memoryLimitMb > 0) {
if (options.alerts.memory && s.state === "running" && s.usage !== null && s.memoryLimitMb !== null && s.memoryLimitMb > 0) {
const share = s.usage.memoryBytes / (s.memoryLimitMb * 1024 ** 2);
if (share >= limit) {
out.push({