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:
1 parent
4a7b1494c8
commit
1ef686d1ba
8 files changed
+58
-15
No files matched your search
+1
-1
@@ -468,7 +468,7 @@ osTicket's API cannot close a ticket, so this is the one place in the app that *
|
||||
|
||||
### Fragnet game servers
|
||||
|
||||
- **Config fields:** the account's **API key** (panel.fragnet.net → your profile → *API Credentials* → create one; it starts with **`ptlc_`** and is shown only once; stored encrypted). It must be the account's own key — an *Application* key (`ptla_`) is for panel administrators and does not work, and the app says so. Optional: the **panel address** (`https://panel.fragnet.net` when left out — fill it in for another Pterodactyl panel, since Fragnet's is a fork of Pterodactyl and this speaks its *client* API), **warn when the newest backup is older than** *n* days (7; 0 turns backups off), **warn when disk or memory is fuller than** *n* % (90) and **servers whose backups are not judged** (names, comma-separated). A key may be limited to certain addresses in the panel; if so, allow the app's.
|
||||
- **Config fields:** the account's **API key** (panel.fragnet.net → your profile → *API Credentials* → create one; it starts with **`ptlc_`** and is shown only once; stored encrypted). It must be the account's own key — an *Application* key (`ptla_`) is for panel administrators and does not work, and the app says so. Optional: the **panel address** (`https://panel.fragnet.net` when left out — fill it in for another Pterodactyl panel, since Fragnet's is a fork of Pterodactyl and this speaks its *client* API), **warn when the newest backup is older than** *n* days (7; 0 turns backups off), **warn when disk or memory is fuller than** *n* % (90), **servers whose backups are not judged** (names, comma-separated) and three tick boxes that switch one kind of alert off for the whole account — **do not alert about disk space**, **memory** or **backups** (the page still shows the figures). A key may be limited to certain addresses in the panel; if so, allow the app's.
|
||||
- **Required access:** `panel.fragnet.net` (HTTPS) reachable from the app. The panel limits the requests per minute (429 when over); a read is four requests for each game server, every five minutes.
|
||||
- **What it does:** every **five minutes** each game server of the account (also those shared with it) is read — the game (the panel's *egg*, for example *Minecraft: Paper*), every IP address and port, SFTP, the plan's memory, disk and CPU limits and its room for backups and databases, whether it is running, what it uses, its backups, schedules and databases. **Infrastructure → Game servers** shows them; a row opens to show every address (click to copy), the backups, the schedules and a link to the server in the game panel.
|
||||
- **Power:** operators can **start, stop, restart and kill** a server from the page (a confirmation first; kill says it loses unsaved progress). It sends exactly that signal to the panel and writes it to the audit log (`start_game_server` …). The page reads again a few seconds later. Beside backups, it is the only thing this integration ever sends but reads, and only a server the last read found can be signalled.
|
||||
|
||||
@@ -345,6 +345,8 @@ An integration of type *Fragnet game servers* ([INTEGRATIONS.md](../INTEGRATIONS
|
||||
| **Disk nearly full** | The server has used 90% of its disk (*warn when disk or memory is fuller than*); critical from 98% — a full disk stops the game saving | warning; critical from 98% |
|
||||
| **Memory nearly full** | The server uses 90% of its memory limit **while it runs** — past the limit the host stops the game | warning |
|
||||
|
||||
Each of the three can be **switched off on its own** in the integration's settings (Administration → Integrations → edit: *Do not alert about disk space / memory / backups*) — for example to hear about disk and backups but not memory. The page keeps showing the figures; a bar for something switched off is blue instead of green, yellow or red, and the backups tile says *not judged*. There is no CPU alert: the CPU is shown on the server's row only.
|
||||
|
||||
A server that is **stopped** is not an alert (game servers are often stopped on purpose), and one that is suspended or being installed is not judged. "Since when" a server has been in its state is **when the app first saw it** in a read. Maintenance on the integration holds the alerts; a reading older than 20 minutes is not believed (they are neither raised nor cleared, and the Alerts page says it could not check). `/metrics` has the running state, disk and memory against their limits and when the newest backup finished.
|
||||
|
||||
## AdGuard Home
|
||||
|
||||
@@ -182,6 +182,9 @@ export const INTEGRATION_FIELDS: Partial<Record<IntegrationType, IntegrationFiel
|
||||
{ key: "backupDays", label: "Warn when the newest backup is older than, days (optional)", secret: false, optional: true, placeholder: "7 — 0 to not judge backups" },
|
||||
{ key: "fullPercent", label: "Warn when disk or memory is fuller than, % (optional)", secret: false, optional: true, placeholder: "90" },
|
||||
{ key: "ignoreBackups", label: "Servers whose backups are not judged (optional)", secret: false, optional: true, placeholder: "names, separated by commas" },
|
||||
{ key: "muteDisk", label: "Do not alert about disk space (the page still shows it)", secret: false, optional: true, type: "checkbox" },
|
||||
{ key: "muteMemory", label: "Do not alert about memory (the page still shows it)", secret: false, optional: true, type: "checkbox" },
|
||||
{ key: "muteBackups", label: "Do not alert about backups (the page still shows them)", secret: false, optional: true, type: "checkbox" },
|
||||
],
|
||||
netbox: [
|
||||
{ key: "url", label: "NetBox URL", secret: false, placeholder: "https://netbox.example.lan" },
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Fragnet game server adapter. Fragnet's game panel (https://panel.fragnet.net) is a fork of Pterodactyl, so this speaks Pterodactyl's *client* API
|
||||
* (https://dashflo.net/docs/api/pterodactyl/v1/#req_…, base `/api/client`). Config: token (the account's API key — the panel's profile menu → API Credentials; it starts with **ptlc_**, an
|
||||
* Application key, ptla_, does not work), optionally url (the panel; https://panel.fragnet.net when left out) and the three that the alerts use (see services/fragnetSync.ts): backupDays,
|
||||
* fullPercent, ignoreBackups.
|
||||
* fullPercent, ignoreBackups, and muteDisk, muteMemory, muteBackups (each switches one kind of alert off).
|
||||
*
|
||||
* Reading: the servers of the account (`GET /api/client`, paged, with the game — the egg — and the addresses) and, for each, `…/resources` (running or not, memory, CPU, disk, uptime), `…/backups`,
|
||||
* `…/schedules` and `…/databases`. A part that cannot be read (a sub-user without that permission gets a 403) is null for that server, which is not the same as none. The only thing ever
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -369,10 +369,42 @@ describe("what is wrong", () => {
|
||||
});
|
||||
|
||||
test("the settings: what is given is used, nonsense falls back to the defaults, names are compared without regard to case", () => {
|
||||
assert.deepEqual({ ...fn.optionsOf(null) }, { backupDays: 7, fullPercent: 90, ignoreBackups: [] });
|
||||
assert.deepEqual({ ...fn.optionsOf({ backupDays: "3", fullPercent: "85,5", ignoreBackups: "Test, Rust\nBuild" }) }, { backupDays: 3, fullPercent: 85.5, ignoreBackups: ["test", "rust", "build"] });
|
||||
assert.deepEqual({ ...fn.optionsOf({ backupDays: "0", fullPercent: "x" }) }, { backupDays: 0, fullPercent: 90, ignoreBackups: [] });
|
||||
assert.deepEqual({ ...fn.optionsOf({ backupDays: "-4" }) }, { backupDays: 7, fullPercent: 90, ignoreBackups: [] });
|
||||
const all = { backups: true, disk: true, memory: true };
|
||||
assert.deepEqual({ ...fn.optionsOf(null) }, { backupDays: 7, fullPercent: 90, ignoreBackups: [], alerts: all });
|
||||
assert.deepEqual({ ...fn.optionsOf({ backupDays: "3", fullPercent: "85,5", ignoreBackups: "Test, Rust\nBuild" }) }, { backupDays: 3, fullPercent: 85.5, ignoreBackups: ["test", "rust", "build"], alerts: all });
|
||||
assert.deepEqual({ ...fn.optionsOf({ backupDays: "0", fullPercent: "x" }) }, { backupDays: 0, fullPercent: 90, ignoreBackups: [], alerts: all });
|
||||
assert.deepEqual({ ...fn.optionsOf({ backupDays: "-4" }) }, { backupDays: 7, fullPercent: 90, ignoreBackups: [], alerts: all });
|
||||
});
|
||||
|
||||
describe("alerts switched off", () => {
|
||||
const use = (diskGb: number, memGb: number) => ({ memoryBytes: memGb * GB, cpu: 10, diskBytes: diskGb * GB, rxBytes: 0, txBytes: 0, uptimeMs: HOUR });
|
||||
// a server with everything wrong at once: no backup, a nearly full disk, memory over the limit
|
||||
const everything = () => stored({ backups: [], usage: use(19, 3.8) });
|
||||
const kinds = (o = opts()) => problems(everything(), o).map((p) => p.key.replace(/:.*$/, "")).sort();
|
||||
|
||||
test("by default every kind is raised", () => {
|
||||
assert.deepEqual(kinds(), ["fragnet-backup", "fragnet-disk", "fragnet-memory"]);
|
||||
});
|
||||
test("memory switched off: no memory alert, disk and backups still are", () => {
|
||||
assert.deepEqual(kinds(fn.optionsOf({ muteMemory: true })), ["fragnet-backup", "fragnet-disk"]);
|
||||
});
|
||||
test("disk switched off, and backups switched off, each on its own", () => {
|
||||
assert.deepEqual(kinds(fn.optionsOf({ muteDisk: true })), ["fragnet-backup", "fragnet-memory"]);
|
||||
assert.deepEqual(kinds(fn.optionsOf({ muteBackups: true })), ["fragnet-disk", "fragnet-memory"]);
|
||||
});
|
||||
test("memory alone left on keeps the others quiet; all three off says nothing", () => {
|
||||
assert.deepEqual(kinds(fn.optionsOf({ muteDisk: true, muteBackups: true })), ["fragnet-memory"]);
|
||||
assert.deepEqual(kinds(fn.optionsOf({ muteDisk: true, muteMemory: true, muteBackups: true })), []);
|
||||
});
|
||||
test("a checkbox is true, or the text true as the settings keep it; anything else leaves the alert on", () => {
|
||||
assert.equal(fn.optionsOf({ muteMemory: "true" }).alerts.memory, false);
|
||||
for (const v of [false, "false", "", "yes", 1, null, undefined]) assert.equal(fn.optionsOf({ muteMemory: v }).alerts.memory, true, JSON.stringify(v));
|
||||
});
|
||||
test("it is the alert that goes, not the reading: the limit and the other servers are untouched", () => {
|
||||
const two = [stored({ backups: [okBackup(DAY, {}, NOW)], usage: use(19, 1) }), { ...stored({ backups: [okBackup(DAY, {}, NOW)], usage: use(1, 3.8) }), id: "zzzz9999", name: "rust" }];
|
||||
const out = fn.fragnetProblems(1, "Fragnet", two, NOW, fn.optionsOf({ muteMemory: true }));
|
||||
assert.deepEqual(out.map((p) => p.key), ["fragnet-disk:1:abcd1234"], "rust's memory is quiet; survival's disk is not");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1533,7 +1533,7 @@ export interface FragnetAccount {
|
||||
panelUrl: string;
|
||||
status: { at: string; ok: boolean; error: string | null } | null;
|
||||
fresh: boolean;
|
||||
options: { backupDays: number; fullPercent: number; ignoreBackups: string[] };
|
||||
options: { backupDays: number; fullPercent: number; ignoreBackups: string[]; /** Which kinds of alert are raised (each can be switched off in the integration's settings). */ alerts: { backups: boolean; disk: boolean; memory: boolean } };
|
||||
state: { servers: FragnetServerInfo[]; updatedAt: string } | null;
|
||||
problems: { key: string; serverId: string; message: string; severity: "warning" | "critical" }[];
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ function StateBadge({ s }: { s: Server }) {
|
||||
}
|
||||
|
||||
/** What is used of a limit, as a bar that turns yellow at the integration's limit for "nearly full" and red near the top. A limit of 0 (or none) is no limit: only the use is written. */
|
||||
function UseBar({ label, used, limitMb, fullPercent }: { label: string; used: number | null; limitMb: number | null; fullPercent: number }) {
|
||||
function UseBar({ label, used, limitMb, fullPercent, alerting = true }: { label: string; used: number | null; limitMb: number | null; fullPercent: number; /** False when the integration is set not to alert about it: the figure stays, and is not coloured as a warning. */ alerting?: boolean }) {
|
||||
if (used === null) return <div className="small text-secondary">{label} —</div>;
|
||||
if (!limitMb || limitMb <= 0) return <div className="small text-secondary">{label} {formatBytes(used)}, no limit</div>;
|
||||
const share = used / (limitMb * MB);
|
||||
return (
|
||||
<div style={{ minWidth: 150 }} className="mb-1">
|
||||
<div className="progress progress-sm">
|
||||
<div className={`progress-bar ${share >= 0.98 ? "bg-red" : share * 100 >= fullPercent ? "bg-yellow" : "bg-green"}`} style={{ width: `${Math.min(100, share * 100)}%` }} />
|
||||
<div className={`progress-bar ${!alerting ? "bg-blue" : share >= 0.98 ? "bg-red" : share * 100 >= fullPercent ? "bg-yellow" : "bg-green"}`} style={{ width: `${Math.min(100, share * 100)}%` }} />
|
||||
</div>
|
||||
<div className="small text-secondary">
|
||||
{label} {formatBytes(used)} of {formatBytes(limitMb * MB)} ({Math.floor(share * 100)}%)
|
||||
@@ -226,8 +226,8 @@ function ServerRow({ a, s, readAt, canAct, open, onToggle, onSignal, onBackup, b
|
||||
{s.allocations.length > 1 && <div className="small text-secondary">+{s.allocations.length - 1} more</div>}
|
||||
</td>
|
||||
<td>
|
||||
<UseBar label="Memory" used={s.state === "running" || s.state === "starting" ? (s.usage?.memoryBytes ?? null) : null} limitMb={s.memoryLimitMb} fullPercent={a.options.fullPercent} />
|
||||
<UseBar label="Disk" used={s.usage?.diskBytes ?? null} limitMb={s.diskLimitMb} fullPercent={a.options.fullPercent} />
|
||||
<UseBar label="Memory" used={s.state === "running" || s.state === "starting" ? (s.usage?.memoryBytes ?? null) : null} limitMb={s.memoryLimitMb} fullPercent={a.options.fullPercent} alerting={a.options.alerts.memory} />
|
||||
<UseBar label="Disk" used={s.usage?.diskBytes ?? null} limitMb={s.diskLimitMb} fullPercent={a.options.fullPercent} alerting={a.options.alerts.disk} />
|
||||
</td>
|
||||
<td className="text-secondary">
|
||||
{backup === null ? (
|
||||
@@ -402,7 +402,7 @@ function Card({ a, canAct, reload }: { a: FragnetAccount; canAct: boolean; reloa
|
||||
<div className="card-body">
|
||||
<div className="text-secondary small">Backups</div>
|
||||
<div className="h2 mb-0">{s.servers.reduce((n, x) => n + (x.backups?.filter((b) => b.completedAt !== null && b.successful).length ?? 0), 0)}</div>
|
||||
<div className="text-secondary small">{a.options.backupDays > 0 ? `one is wanted every ${a.options.backupDays} days` : "not judged"}</div>
|
||||
<div className="text-secondary small">{a.options.backupDays > 0 && a.options.alerts.backups ? `one is wanted every ${a.options.backupDays} days` : "not judged"}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user