Fragnet: reads checked against a live account; interval and one-off schedules

Inspect on a real Fragnet panel showed every read answers as the reader expects. Schedules that run every so often or once (interval_value, interval_unit, run_at) carry no cron fields, so they were shown as a cron of stars; they now read "every 6 hours" or "once, ...", and the page hides an empty label. Test and INTEGRATIONS.md updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-17 19:19:48 +01:00
1 parent 01fb5d6335
commit a91efcbfe2
4 files changed
+31 -5

No files matched your search

+1 -1
View File
@@ -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). - **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. - 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`. - `/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 ### AdGuard Home
+18 -3
View File
@@ -241,6 +241,23 @@ export function parseNewBackup(raw: unknown): FragnetBackup | null {
return parseBackups({ data: [raw] })[0] ?? 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, unknown>): 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). */ /** Pure: `…/schedules` — the tasks that run on their own (a restart every night, a backup every Sunday). */
export function parseSchedules(raw: unknown): FragnetSchedule[] { export function parseSchedules(raw: unknown): FragnetSchedule[] {
const out: FragnetSchedule[] = []; const out: FragnetSchedule[] = [];
@@ -249,9 +266,7 @@ export function parseSchedules(raw: unknown): FragnetSchedule[] {
const id = num(s.id); const id = num(s.id);
const name = str(s.name); const name = str(s.name);
if (id === null || !name) continue; if (id === null || !name) continue;
const c = obj(s.cron); 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) });
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) });
} }
return out; return out;
} }
+11
View File
@@ -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"]); 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<string, unknown>) => 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", () => { 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: 1, total_pages: 2 } } }), 2);
assert.equal(adapter.nextPage({ meta: { pagination: { current_page: 2, total_pages: 2 } } }), null); assert.equal(adapter.nextPage({ meta: { pagination: { current_page: 2, total_pages: 2 } } }), null);
+1 -1
View File
@@ -233,7 +233,7 @@ function Details({ s, panelUrl, canAct, onSignal, onBackup, busy }: { s: Server;
<ul className="list-unstyled mb-0"> <ul className="list-unstyled mb-0">
{s.schedules?.map((x) => ( {s.schedules?.map((x) => (
<li key={x.id}> <li key={x.id}>
<strong>{x.name}</strong> {!x.active && <span className="badge bg-secondary-lt text-secondary">off</span>} <code className="small">{x.cron}</code> <strong>{x.name}</strong> {!x.active && <span className="badge bg-secondary-lt text-secondary">off</span>} {x.cron && <code className="small">{x.cron}</code>}
<div className="small text-secondary"> <div className="small text-secondary">
{x.lastRunAt ? ( {x.lastRunAt ? (
<> <>