Fragnet game servers: games, addresses, backups, power actions

New integration kind "fragnet" reading Fragnet's Pterodactyl-based panel through the
client API (account key). Game servers page under Infrastructure with game, IP:port,
state, memory/disk, backups, schedules and databases; alerts for late backups and
nearly full disk/memory; operators can start/stop/restart/kill (audited). Metrics,
docs and tests included; migration 0071 adds fragnet_state.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-27 19:01:36 +01:00
1 parent f86661f6c9
commit 9a3d5c466a
29 files changed
+9836 -8

No files matched your search

+25 -1
View File
@@ -5,7 +5,7 @@
*/
import { eq } from "drizzle-orm";
import { db } from "../db/client.js";
import { assets, endpointChecks, heartbeats, integrations, maintenanceWindows, secrets, servers, upsState, jellyfinState, authentikState, immichState, paperlessState, nextcloudState, netboxState, n8nState, dockhandVulnerabilities, hetznerState } from "../db/schema.js";
import { assets, endpointChecks, heartbeats, integrations, maintenanceWindows, secrets, servers, upsState, jellyfinState, authentikState, immichState, paperlessState, nextcloudState, netboxState, n8nState, dockhandVulnerabilities, hetznerState, fragnetState } from "../db/schema.js";
import { isUpsFresh, upsSyncStatuses } from "./upsSync.js";
import { levelStatuses } from "./serviceLevels.js";
import { backupState, listAll as listDuplicati } from "./duplicati.js";
@@ -14,6 +14,7 @@ import { isNextcloudFresh, nextcloudSyncStatuses } from "./nextcloudSync.js";
import { dockerVulnSyncStatuses, isDockerVulnFresh } from "./dockerVulnSync.js";
import { isSpeedtestFresh, recentResults as recentSpeedtestResults, speedtestSyncStatuses } from "./speedtestSync.js";
import { costOf as hetznerCostOf, hetznerSyncStatuses, isHetznerFresh, serversOf as hetznerServersOf } from "./hetznerSync.js";
import { fragnetSyncStatuses, isFragnetFresh, newestBackup as fragnetNewestBackup, serversOf as fragnetServersOf } from "./fragnetSync.js";
import { isNetBoxFresh, netboxSyncStatuses } from "./netboxSync.js";
import { isN8nFresh, n8nSyncStatuses, workflowsOf as n8nWorkflowsOf } from "./n8nSync.js";
import { componentsOf as paperlessComponentsOf, failedOf as paperlessFailedOf, isPaperlessFresh, paperlessSyncStatuses } from "./paperlessSync.js";
@@ -100,6 +101,28 @@ async function addSpeedtestMetrics(out: Exposition, now: Date) {
}
}
/** Each Fragnet game server, for /metrics: whether it is running, its disk and memory against their limits and when it was last backed up. Only while the reading is recent. */
async function addFragnetMetrics(out: Exposition, now: Date) {
const statuses = await fragnetSyncStatuses();
const names = new Map((await db.select({ id: integrations.id, name: integrations.name, enabled: integrations.enabled }).from(integrations).where(eq(integrations.type, "fragnet"))).map((r) => [r.id, r]));
for (const s of await db.select().from(fragnetState)) {
const row = names.get(s.integrationId);
if (!row || !row.enabled || !isFragnetFresh(statuses[s.integrationId], now.getTime())) continue;
for (const server of fragnetServersOf(s)) {
const labels = { account: row.name, server: server.name, game: server.game ?? "" };
out.add("homelab_fragnet_server_running", "gauge", "1 if the Fragnet game server is running, else 0.", server.state === "running" ? 1 : 0, labels);
if (server.usage) {
out.add("homelab_fragnet_disk_used_bytes", "gauge", "Disk a Fragnet game server uses, in bytes.", server.usage.diskBytes, labels);
out.add("homelab_fragnet_memory_used_bytes", "gauge", "Memory a Fragnet game server uses, in bytes.", server.usage.memoryBytes, labels);
}
if (server.diskLimitMb) out.add("homelab_fragnet_disk_limit_bytes", "gauge", "The disk a Fragnet game server may use, in bytes.", server.diskLimitMb * 1024 ** 2, labels);
if (server.memoryLimitMb) out.add("homelab_fragnet_memory_limit_bytes", "gauge", "The memory a Fragnet game server may use, in bytes.", server.memoryLimitMb * 1024 ** 2, labels);
const backedUp = fragnetNewestBackup(server)?.at;
if (backedUp) out.add("homelab_fragnet_newest_backup_timestamp_seconds", "gauge", "When the newest successful backup of a Fragnet game server finished, in seconds since 1970.", Date.parse(backedUp) / 1000, labels);
}
}
}
/** Each Hetzner Cloud server, for /metrics: whether it is running, its traffic this month against the quota, and the project's monthly cost estimate. Only while the reading is recent. */
async function addHetznerMetrics(out: Exposition, now: Date) {
const statuses = await hetznerSyncStatuses();
@@ -442,6 +465,7 @@ export async function buildMetrics(now: Date = new Date()): Promise<string> {
await addDockerVulnMetrics(out, now);
await addHetznerMetrics(out, now);
await addSpeedtestMetrics(out, now);
await addFragnetMetrics(out, now);
await addHeartbeatMetrics(out, now);
return out.toString();
}