diff --git a/INTEGRATIONS.md b/INTEGRATIONS.md index 3b1a0c9..efa211e 100644 --- a/INTEGRATIONS.md +++ b/INTEGRATIONS.md @@ -492,7 +492,7 @@ osTicket's API cannot close a ticket, so this is the one place in the app that * - **Power history.** Every change a read sees (turned on, turned off) is written down, and so is each Start, Stop, Restart or Kill sent from here with who sent it, so a row's details have a **Power history**: the share of the last 30 days (or of what has been watched, when less) that the server was on, how many times it started and stopped, a bar for the last seven days (green on, grey off), and the latest changes — *"Turned on — start by Ada"* when the change followed a signal sent from here in the 20 minutes before. It is what this app saw: the account is read every five minutes, so every time is to the nearest five, and nothing is known of the time before a server was first read. Kept 180 days; it goes with the integration. See [MONITORING.md](docs/MONITORING.md#game-servers-fragnet). - If the panel cannot be read for 20 minutes its alerts are neither raised nor cleared, the Alerts page says it could not check, and the integration is raised as failing like any other. A part that cannot be read for one server (a sub-user without the *database* permission, say) is shown as *could not be listed*, never as none. - `/metrics` has `homelab_fragnet_server_running`, `homelab_fragnet_disk_used_bytes`, `homelab_fragnet_disk_limit_bytes`, `homelab_fragnet_memory_used_bytes`, `homelab_fragnet_memory_limit_bytes` and `homelab_fragnet_newest_backup_timestamp_seconds`. -- **Not verified against a live account** — the endpoints (`/api/client?include=egg,allocations`, `/servers/{id}/resources`, `…/backups`, `…/schedules`, `…/databases`, `POST …/power`) and their fields are as Pterodactyl's own source and Fragnet's documentation have them, and the reader is tried against a pretend panel. Fragnet's fork may differ: the game is left out (shown as the Docker image) if the panel does not send the egg, and a panel that refuses the extra `include` is asked again plainly. Disk and memory limits are in MB as the panel counts them and shown in binary units. What the servers cost is not in the API: add it under Records → Costs. +- **Reads checked against a live account** (Inspect, four servers: the server list with its egg and allocations, `…/resources`, `…/backups`, `…/schedules` and `…/databases` all answered as the reader expects; the fields it leaves empty — description, panel status, allocation notes — were empty in the answer too). **Not checked live:** `POST …/power` and `POST …/backups`, which are as Pterodactyl's own source and Fragnet's documentation have them. A server can carry a second kind of schedule (every so often, or once, with `interval_value`/`interval_unit`/`run_at`, not a cron): it reads "every 6 hours" or "once, …" instead of a cron. Fragnet's fork may differ: the game is left out (shown as the Docker image) if the panel does not send the egg, and a panel that refuses the extra `include` is asked again plainly. Disk and memory limits are in MB as the panel counts them and shown in binary units. What the servers cost is not in the API: add it under Records → Costs. ### AdGuard Home diff --git a/server/src/integrations/fragnet/adapter.ts b/server/src/integrations/fragnet/adapter.ts index f09e5b4..a0d874b 100644 --- a/server/src/integrations/fragnet/adapter.ts +++ b/server/src/integrations/fragnet/adapter.ts @@ -241,6 +241,23 @@ export function parseNewBackup(raw: unknown): FragnetBackup | null { return parseBackups({ data: [raw] })[0] ?? null; } +/** + * When a schedule runs, as one line. Most carry a cron (the five fields, joined); the panel also has schedules that run every so often (`has_interval`, `interval_value`, `interval_unit`) or + * once (`run_at`), whose cron object says nothing — those read "every 6 hours" or "once, 2026-06-02 04:00", rather than a cron of stars that would claim "every minute". + */ +function whenItRuns(s: Record): string { + const c = obj(s.cron); + const fields = [c.minute, c.hour, c.day_of_month, c.month, c.day_of_week]; + const given = (x: unknown) => (typeof x === "string" && x.trim() !== "") || typeof x === "number"; + if (fields.some(given)) return fields.map((x) => (given(x) ? String(x) : "*")).join(" "); + const every = num(s.interval_value); + const unit = str(s.interval_unit); + if (s.has_interval === true && every !== null && every > 0 && unit) return `every ${every === 1 ? "" : `${every} `}${unit.replace(/s$/i, "")}${every === 1 ? "" : "s"}`; + const once = iso(s.run_at); + if (once) return `once, ${once.slice(0, 16).replace("T", " ")}`; + return ""; +} + /** Pure: `…/schedules` — the tasks that run on their own (a restart every night, a backup every Sunday). */ export function parseSchedules(raw: unknown): FragnetSchedule[] { const out: FragnetSchedule[] = []; @@ -249,9 +266,7 @@ export function parseSchedules(raw: unknown): FragnetSchedule[] { const id = num(s.id); const name = str(s.name); if (id === null || !name) continue; - const c = obj(s.cron); - const cron = [c.minute, c.hour, c.day_of_month, c.month, c.day_of_week].map((x) => (typeof x === "string" || typeof x === "number" ? String(x) : "*")).join(" "); - out.push({ id, name, cron, active: s.is_active !== false, processing: s.is_processing === true, onlyWhenOnline: s.only_when_online === true, lastRunAt: iso(s.last_run_at), nextRunAt: iso(s.next_run_at) }); + out.push({ id, name, cron: whenItRuns(s), active: s.is_active !== false, processing: s.is_processing === true, onlyWhenOnline: s.only_when_online === true, lastRunAt: iso(s.last_run_at), nextRunAt: iso(s.next_run_at) }); } return out; } diff --git a/server/test/fragnet.test.ts b/server/test/fragnet.test.ts index 5d86380..044a2c6 100644 --- a/server/test/fragnet.test.ts +++ b/server/test/fragnet.test.ts @@ -136,6 +136,17 @@ describe("what the panel's API says", () => { assert.deepEqual([s.id, s.name, s.cron, s.active, s.onlyWhenOnline, s.nextRunAt], [4, "Nightly restart", "0 4 * * *", true, true, "2026-06-02T04:00:00.000Z"]); }); + test("a schedule that runs every so often or once is not shown as a cron of stars", () => { + const run = (attributes: Record) => adapter.parseSchedules({ data: [{ attributes: { id: 1, name: "x", ...attributes } }] })[0].cron; + const none = { minute: "", hour: "", day_of_month: "", month: "", day_of_week: "" }; + assert.equal(run({ cron: none, has_interval: true, interval_value: 6, interval_unit: "hours", run_at: "2026-06-02T04:00:00+00:00" }), "every 6 hours"); + assert.equal(run({ cron: {}, has_interval: true, interval_value: 1, interval_unit: "hour" }), "every hour"); + assert.equal(run({ cron: none, has_interval: false, run_at: "2026-06-02T04:00:00+00:00" }), "once, 2026-06-02 04:00"); + assert.equal(run({ cron: none }), "", "nothing known says nothing"); + assert.equal(run({ cron: { minute: "*/5", hour: "*", day_of_month: "*", month: "*", day_of_week: "*" } }), "*/5 * * * *"); + assert.equal(run({ cron: { minute: "0", hour: "4" } }), "0 4 * * *", "a cron with fields left out keeps its stars"); + }); + test("the next page is the one after this, up to the last", () => { assert.equal(adapter.nextPage({ meta: { pagination: { current_page: 1, total_pages: 2 } } }), 2); assert.equal(adapter.nextPage({ meta: { pagination: { current_page: 2, total_pages: 2 } } }), null); diff --git a/web/src/pages/GameServers.tsx b/web/src/pages/GameServers.tsx index 3a65f1f..a6a38dc 100644 --- a/web/src/pages/GameServers.tsx +++ b/web/src/pages/GameServers.tsx @@ -233,7 +233,7 @@ function Details({ s, panelUrl, canAct, onSignal, onBackup, busy }: { s: Server;