Lidarr/Readarr, integration inspector, app versions, grouped alerts

Lidarr and Readarr join the shared *arr reader. Integrations get an Inspect button that
runs the reader once and shows what each request returned as shapes (never values) and
where the result is empty. Operations -> App versions compares each application's version
with its newest GitHub release (lookup off until an admin switches it on; optional alert).
The Alerts page can group by source, kind of problem or type of alert. The shared HTTP
helper no longer reuses connections (stale-socket resets). Migration 0078; docs and tests
included.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-29 20:07:36 +01:00
1 parent 551eb1597a
commit 93aaf5476d
45 files changed
+10033 -65

No files matched your search

+2
View File
@@ -52,6 +52,7 @@ import Alerts from "./pages/Alerts";
import Generator from "./pages/Generator";
import Maintenance from "./pages/Maintenance";
import Updates from "./pages/Updates";
import Versions from "./pages/Versions";
import IncidentDetail from "./pages/IncidentDetail";
import Inventory from "./pages/Inventory";
import InventoryLabels from "./pages/InventoryLabels";
@@ -184,6 +185,7 @@ function Shelled({ user }: { user: CurrentUser }) {
<Route path="/hetzner" element={<Hetzner />} />
<Route path="/game-servers" element={<GameServers user={user} />} />
<Route path="/media" element={<Media />} />
<Route path="/versions" element={<Versions user={user} />} />
<Route path="/adguard" element={<AdguardHome />} />
<Route path="/grafana" element={<Grafana />} />
<Route path="/speedtest" element={<Speedtest />} />
+39 -2
View File
@@ -1463,7 +1463,7 @@ export interface FragnetAccount {
/** One Sonarr, Radarr or Prowlarr (an integration of that type), as the media page shows it. */
export interface ArrApp {
id: number;
kind: "sonarr" | "radarr" | "prowlarr";
kind: "sonarr" | "radarr" | "prowlarr" | "lidarr" | "readarr";
name: string;
enabled: boolean;
url: string;
@@ -1528,6 +1528,37 @@ export interface GrafanaInstance {
problems: { key: string; message: string; severity: "warning" | "critical" }[];
}
/** What running an integration's reader once showed: each request it made (and the shape of the answer, never its values), what it made of them, and where that is empty. */
export interface IntegrationInspection {
type: IntegrationType;
name: string;
ok: boolean;
error: string | null;
ms: number;
calls: { method: string; path: string; status: number; ms: number; bytes: number; shape: string | null; error?: string }[];
resultShape: string | null;
empty: { path: string; what: "null" | "text" | "list" | "every-item" }[];
}
/** What each connected application runs, against the newest release kept for it. */
export interface AppVersions {
enabled: boolean;
alertAfterDays: number;
lastCheckedAt: string | null;
rows: {
integrationId: number;
type: string;
label: string;
name: string;
running: string;
latest: { tag: string; publishedAt: string | null; url: string | null } | null;
lookupError: string | null;
lag: "same" | "patch" | "minor" | "major" | "ahead" | "unknown";
daysOut: number | null;
checkedAt: string | null;
}[];
}
export type FragnetSignal = "start" | "stop" | "restart" | "kill";
export interface CostItem {
@@ -2663,7 +2694,7 @@ export interface ManualTaskInput {
enabled?: boolean;
}
export type IntegrationType = "proxmox" | "synology" | "semaphore" | "tailscale" | "gitea" | "dockhand" | "uptimekuma" | "phpipam" | "pbs" | "osticket" | "unifi" | "npm" | "homeassistant" | "ups" | "jellyfin" | "authentik" | "prometheus" | "immich" | "paperless" | "nextcloud" | "netbox" | "n8n" | "hetzner" | "speedtest" | "fragnet" | "sonarr" | "radarr" | "prowlarr" | "adguard" | "grafana";
export type IntegrationType = "proxmox" | "synology" | "semaphore" | "tailscale" | "gitea" | "dockhand" | "uptimekuma" | "phpipam" | "pbs" | "osticket" | "unifi" | "npm" | "homeassistant" | "ups" | "jellyfin" | "authentik" | "prometheus" | "immich" | "paperless" | "nextcloud" | "netbox" | "n8n" | "hetzner" | "speedtest" | "fragnet" | "sonarr" | "radarr" | "prowlarr" | "adguard" | "grafana" | "lidarr" | "readarr";
export interface IntegrationField {
key: string;
@@ -3265,6 +3296,11 @@ export const api = {
list: () => request<{ speedtests: SpeedtestInfo[] }>("/api/speedtest"),
history: (id: number, days: number) => request<SpeedtestHistory>(`/api/speedtest/${id}/history?days=${days}`),
},
versions: {
get: () => request<AppVersions>("/api/versions"),
save: (data: { enabled: boolean; alertAfterDays: number }) => request<AppVersions>("/api/versions/settings", { method: "PUT", body: JSON.stringify(data) }),
refresh: () => request<AppVersions & { result: { checked: number; failed: number } }>("/api/versions/refresh", { method: "POST" }),
},
adguard: {
list: () => request<{ instances: AdguardInstance[] }>("/api/adguard"),
},
@@ -3843,6 +3879,7 @@ export const api = {
integration: { id: number; type: IntegrationType; name: string; enabled: boolean };
config: Record<string, string | boolean>;
}>(`/api/integrations/${id}/config`),
inspect: (id: number) => request<IntegrationInspection>(`/api/integrations/${id}/inspect`, { method: "POST" }),
testExisting: (id: number, config: Record<string, string | boolean>) =>
request<{ ok: boolean; latencyMs?: number; error?: string }>(`/api/integrations/${id}/test`, {
method: "POST",
+24
View File
@@ -0,0 +1,24 @@
import type { AlertGroup } from "../utils/alertGroups";
/** The header row of one group: fold it, and pick everything in it. */
export default function AlertGroupRow({ group, colSpan, canPick, allPicked, onToggle, onPick }: { group: AlertGroup; colSpan: number; canPick: boolean; allPicked: boolean; onToggle: () => void; onPick: () => void }) {
return (
<tr className="alert-group-row">
<td colSpan={colSpan} className="bg-body-tertiary py-2">
<div className="d-flex flex-wrap align-items-center gap-2">
{canPick && group.pickable.length > 0 && <input type="checkbox" className="form-check-input align-middle" aria-label={`Pick all in ${group.label}`} checked={allPicked} onChange={onPick} />}
<button type="button" className="btn btn-link btn-sm p-0 text-reset text-decoration-none fw-bold" aria-expanded={!group.folded} onClick={onToggle}>
<span aria-hidden="true">{group.folded ? "▸" : "▾"}</span> {group.label}
</button>
<span className="text-secondary small">
{group.count} {group.count === 1 ? "alert" : "alerts"}
</span>
{group.critical > 0 && <span className="badge bg-red-lt text-red">{group.critical} critical</span>}
{group.warning > 0 && <span className="badge bg-yellow-lt text-yellow">{group.warning} warning</span>}
{group.info > 0 && <span className="badge bg-blue-lt text-blue">{group.info} info</span>}
{group.silenced > 0 && <span className="badge bg-secondary-lt text-secondary">{group.silenced} held back</span>}
</div>
</td>
</tr>
);
}
+1 -32
View File
@@ -5,42 +5,11 @@ import { ALERT_KIND_RUNBOOKS_CHANGED, useAlertKindRunbooks } from "../hooks/useA
import { readableError } from "../utils/errors";
import { removeWithUndo } from "../utils/undoable";
import { toast } from "../utils/toast";
import { kindWords } from "../utils/alertKinds";
import DetailDrawer from "./DetailDrawer";
import RunbookText from "./RunbookText";
import TimeAgo from "./TimeAgo";
/** How a kind of alert reads in a sentence; any kind not listed is its own name with the dashes taken out. */
const KIND_WORDS: Record<string, string> = {
offline: "a server that stopped reporting",
disk: "a disk filling up",
"failed-units": "failed services",
smart: "a disk reporting trouble",
zfs: "a ZFS pool in trouble",
"docker-vuln": "critical vulnerabilities in Docker images",
"docker-vuln-high": "many high vulnerabilities in Docker images",
"container-restarting": "a container that keeps restarting",
"container-unhealthy": "an unhealthy container",
"container-stopped": "a container that stopped",
"hetzner-off": "a Hetzner server that is off",
"hetzner-traffic": "a Hetzner traffic quota nearly used",
"hetzner-forecast": "a Hetzner traffic quota the month will pass",
"hetzner-backup": "a Hetzner backup that is late",
"hetzner-lb": "an unhealthy Hetzner load balancer",
"hetzner-cert": "a Hetzner certificate about to end",
"hetzner-fip": "a Hetzner floating IP pointing at nothing",
"fragnet-backup": "a game server backup that is late",
"fragnet-disk": "a game server disk filling up",
"fragnet-memory": "a game server's memory running out",
"sonarr-health": "Sonarr reporting a problem",
"sonarr-queue": "stuck downloads in Sonarr",
"radarr-health": "Radarr reporting a problem",
"radarr-queue": "stuck downloads in Radarr",
"prowlarr-health": "Prowlarr reporting a problem",
"speedtest-slow": "a slow internet line",
"speedtest-failing": "failing speed tests",
};
export const kindWords = (kind: string): string => KIND_WORDS[kind] ?? `${kind.replace(/[-_]+/g, " ")} alerts`;
/**
* A small "What to do" link beside an alert: what is written down for this KIND of alert, whichever server or integration it is about (the runbooks of one thing
+132
View File
@@ -0,0 +1,132 @@
import { useEffect, useState } from "react";
import { IconCopy } from "@tabler/icons-react";
import { api, type IntegrationInspection, type IntegrationSummary } from "../api/client";
import { readableError } from "../utils/errors";
import { toast } from "../utils/toast";
import { TYPE_LABELS } from "../utils/integrationTypes";
import DetailDrawer from "./DetailDrawer";
import { BlockSkeleton } from "./Skeleton";
const EMPTY_WORDS: Record<IntegrationInspection["empty"][number]["what"], string> = {
null: "is empty (null)",
text: "is an empty text",
list: "is an empty list",
"every-item": "is empty in every item of the list",
};
/** The report as plain text, to be pasted into a message: only shapes, no values. */
function reportText(i: IntegrationSummary, r: IntegrationInspection): string {
const lines = [`Inspection of ${TYPE_LABELS[i.type]} "${i.name}" — ${r.ok ? "the read worked" : `the read failed: ${r.error}`} (${r.ms} ms)`, ""];
lines.push("What was asked and what came back:");
for (const c of r.calls) {
lines.push(` ${c.method} ${c.path} → ${c.status === 0 ? `no answer (${c.error ?? "?"})` : c.status} · ${c.ms} ms · ${c.bytes} bytes`);
if (c.shape) lines.push(` ${c.shape}`);
}
lines.push("", "What the reader made of it:", ` ${r.resultShape ?? "(nothing)"}`, "", "Empty in it:");
if (r.empty.length === 0) lines.push(" nothing");
for (const e of r.empty) lines.push(` ${e.path} ${EMPTY_WORDS[e.what]}`);
return lines.join("\n");
}
/**
* Runs one integration's reader here and now and shows what it asked, what came back (the shape of each answer — names and kinds of values, never the values) and where what the reader made of
* it is empty. For checking a reader written from documentation against the real system: an answer with a field the reader did not expect shows as an empty field below.
*/
export default function IntegrationInspector({ integration, onClose }: { integration: IntegrationSummary; onClose: () => void }) {
const [report, setReport] = useState<IntegrationInspection | null>(null);
const [error, setError] = useState<string | null>(null);
const [run, setRun] = useState(0);
useEffect(() => {
let alive = true;
setReport(null);
setError(null);
api.integrations
.inspect(integration.id)
.then((r) => alive && setReport(r))
.catch((err) => alive && setError(readableError(err)));
return () => {
alive = false;
};
}, [integration.id, run]);
return (
<DetailDrawer title="Check what can be read" subtitle={`${TYPE_LABELS[integration.type]} · ${integration.name}`} onClose={onClose}>
<p className="text-secondary small">
Reads it once, now, as the app does every few minutes, and shows what each request got back. Only the <strong>names and kinds</strong> of the values are shown — never the values — so the report can be copied into a message. Nothing is stored or changed.
</p>
{!report && !error && <BlockSkeleton lines={4} />}
{error && <div className="text-danger mb-3">{error}</div>}
{report && (
<>
<div className="d-flex flex-wrap align-items-center gap-2 mb-3">
{report.ok ? <span className="badge bg-green-lt text-green">The read worked</span> : <span className="badge bg-red-lt text-red">The read failed</span>}
<span className="text-secondary small">{report.ms} ms · {report.calls.length} {report.calls.length === 1 ? "request" : "requests"}</span>
<span className="ms-auto btn-list flex-nowrap">
<button type="button" className="btn btn-sm" onClick={() => setRun((n) => n + 1)}>
Again
</button>
<button
type="button"
className="btn btn-sm d-inline-flex align-items-center gap-1"
onClick={() => {
void navigator.clipboard?.writeText(reportText(integration, report)).then(
() => toast.success("Copied the report."),
() => toast.error("Couldn't copy it."),
);
}}
>
<IconCopy size={14} aria-hidden="true" /> Copy the report
</button>
</span>
</div>
{report.error && <div className="text-red mb-3">{report.error}</div>}
<h4>What was asked</h4>
{report.calls.length === 0 && <div className="text-secondary small mb-3">No request was made through the shared helper.</div>}
{report.calls.map((c, i) => (
<div key={i} className="border rounded p-2 mb-2">
<div className="d-flex flex-wrap align-items-center gap-2">
<code className="text-break">
{c.method} {c.path}
</code>
{c.status === 0 ? <span className="badge bg-red-lt text-red">no answer</span> : c.status >= 200 && c.status < 300 ? <span className="badge bg-green-lt text-green">{c.status}</span> : <span className="badge bg-yellow-lt text-yellow">{c.status}</span>}
<span className="text-secondary small ms-auto">
{c.ms} ms · {c.bytes.toLocaleString()} bytes
</span>
</div>
{c.error && <div className="text-red small">{c.error}</div>}
{c.shape && <pre className="small text-secondary mb-0 mt-1" style={{ whiteSpace: "pre-wrap", wordBreak: "break-word" }}>{c.shape}</pre>}
{!c.shape && c.status !== 0 && <div className="text-secondary small">The answer was not JSON{c.bytes === 0 ? " (it was empty)" : ""}.</div>}
</div>
))}
<h4 className="mt-3">What the reader made of it</h4>
{report.resultShape ? (
<pre className="small text-secondary" style={{ whiteSpace: "pre-wrap", wordBreak: "break-word" }}>{report.resultShape}</pre>
) : (
<div className="text-secondary small">Nothing — the read failed.</div>
)}
<h4 className="mt-3">Empty in it</h4>
{report.empty.length === 0 ? (
<div className="text-secondary small">Nothing: every field it reads has something in it.</div>
) : (
<>
<p className="text-secondary small">
Often right (no containers, nothing wrong), but where an answer has a field the reader did not expect — named another way, nested somewhere else — it ends up here. Compare with what came back above.
</p>
<ul className="small">
{report.empty.map((e) => (
<li key={`${e.path}-${e.what}`}>
<code>{e.path}</code> {EMPTY_WORDS[e.what]}
</li>
))}
</ul>
</>
)}
</>
)}
</DetailDrawer>
);
}
+2
View File
@@ -36,6 +36,8 @@ const TYPE_LABELS: Record<string, string> = {
prowlarr: "Prowlarr",
adguard: "AdGuard Home",
grafana: "Grafana",
lidarr: "Lidarr",
readarr: "Readarr",
};
export type WallLevel = "critical" | "warning" | "ok" | "unsure";
+2
View File
@@ -49,6 +49,7 @@ import {
IconGitCommit,
IconShieldCheck,
IconShieldLock,
IconVersions,
IconChartAreaLine,
IconActivityHeartbeat,
IconCopyCheck,
@@ -178,6 +179,7 @@ export const NAV: NavEntry[] = [
items: [
{ to: "/maintenance", label: "Maintenance", icon: <IconTool size={20} /> },
{ to: "/updates", label: "Updates", icon: <IconDownload size={20} /> },
{ to: "/versions", label: "App versions", icon: <IconVersions size={20} /> },
{ to: "/coming-up", label: "Coming up", icon: <IconCalendarEvent size={20} /> },
{ to: "/todo", label: "To do", icon: <IconListDetails size={20} /> },
{ to: "/osticket", label: "osTicket", icon: <IconTicket size={20} /> },
+53 -2
View File
@@ -16,6 +16,8 @@ import SilenceButton from "../components/SilenceButton";
import RunPlaybookButton from "../components/RunPlaybookButton";
import RunbookEntry from "../components/RunbookEntry";
import AlertKindRunbookEntry from "../components/AlertKindRunbook";
import AlertGroupRow from "../components/AlertGroupRow";
import { GROUP_BY_LABELS, groupAlerts, isGroup, type GroupBy } from "../utils/alertGroups";
import AckDrawer, { ackWords } from "../components/AckDrawer";
import CloseDrawer, { CloseBulkDrawer } from "../components/CloseDrawer";
import SnoozeDrawer, { SnoozeBulkDrawer, snoozeWords } from "../components/SnoozeDrawer";
@@ -122,6 +124,25 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
}
});
const [open, setOpen] = useState<Set<string>>(new Set());
// The alerts in groups — by where they come from, what kind of problem, or what type of alert — each group folding away; remembered. (Not the same as the nesting above, which is by cause.)
const [groupBy, setGroupBy] = useState<GroupBy>(() => {
try {
const v = localStorage.getItem("alerts.groupBy");
return v === "source" || v === "category" || v === "kind" ? v : "none";
} catch {
return "none";
}
});
const [foldedGroups, setFoldedGroups] = useState<Set<string>>(new Set());
function chooseGroupBy(by: GroupBy) {
setGroupBy(by);
setFoldedGroups(new Set());
try {
localStorage.setItem("alerts.groupBy", by);
} catch {
// a remembered choice is only a convenience
}
}
function chooseGrouped(on: boolean) {
setGrouped(on);
try {
@@ -182,6 +203,17 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
const { sorted, sortKey, sortDir, requestSort } = useSortable(rows);
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
// Grouped, every alert is shown (a page is cut across groups); not grouped, a page at a time.
const shown = useMemo(() => groupAlerts(groupBy === "none" ? (pageItems ?? []) : (sorted ?? []), groupBy, foldedGroups, (c) => CATEGORY_LABELS[c]), [groupBy, pageItems, sorted, foldedGroups]);
function toggleGroup(id: string) {
setFoldedGroups((prev) => {
const next = new Set(prev);
if (next.has(id)) next.delete(id);
else next.add(id);
return next;
});
}
const presentCategories = useMemo(() => [...new Set((report?.alerts ?? []).map((a) => a.category))], [report]);
function exportCsv() {
@@ -225,6 +257,15 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
return next;
});
}
/** Ticks everything in a group that can be ticked — or, when all of it is, unticks it. */
function pickGroup(ids: string[]) {
setPicked((prev) => {
const next = new Set(prev);
if (ids.length > 0 && ids.every((id) => next.has(id))) for (const id of ids) next.delete(id);
else for (const id of ids) next.add(id);
return next;
});
}
function afterBulk() {
void load(true);
reloadBadge();
@@ -429,6 +470,13 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
<option value="warning">Warning</option>
<option value="info">Info</option>
</select>
<select className="form-select form-select-sm w-auto" value={groupBy} aria-label="Grouping" onChange={(e) => chooseGroupBy(e.target.value as GroupBy)}>
{(Object.keys(GROUP_BY_LABELS) as GroupBy[]).map((g) => (
<option key={g} value={g}>
{GROUP_BY_LABELS[g]}
</option>
))}
</select>
<select className="form-select form-select-sm w-auto" value={category} onChange={(e) => setCategory(e.target.value as "all" | AlertCategory)}>
<option value="all">All kinds</option>
{presentCategories.map((c) => (
@@ -496,7 +544,10 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
</tr>
</thead>
<tbody>
{(pageItems ?? []).map((a) => (
{shown.map((a) =>
isGroup(a) ? (
<AlertGroupRow key={a.id} group={a} colSpan={canSilence ? 5 : 4} canPick={canSilence} allPicked={a.pickable.length > 0 && a.pickable.every((id) => picked.has(id))} onToggle={() => toggleGroup(a.id)} onPick={() => pickGroup(a.pickable)} />
) : (
<Fragment key={a.id}>
<tr className={`alert-row alert-row-${a.severity}${a.silenced ? " text-secondary" : ""}`} style={a.silenced ? { opacity: 0.65 } : undefined}>
<td>
@@ -648,7 +699,7 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
</tbody>
</table>
</div>
<Pagination page={page} pageCount={pageCount} totalCount={totalCount} onPageChange={setPage} />
{groupBy === "none" && <Pagination page={page} pageCount={pageCount} totalCount={totalCount} onPageChange={setPage} />}
</div>
)}
</>
+9 -1
View File
@@ -13,7 +13,8 @@ import { ErrorNotice } from "../components/Notice";
import { toast } from "../utils/toast";
import UptimeRibbon from "../components/UptimeRibbon";
import RunbookEntry from "../components/RunbookEntry";
import { groupOfType, TYPE_GROUPS, TYPE_LABELS, TYPE_PAGES } from "../utils/integrationTypes";
import IntegrationInspector from "../components/IntegrationInspector";
import { groupOfType, INSPECTABLE, TYPE_GROUPS, TYPE_LABELS, TYPE_PAGES } from "../utils/integrationTypes";
/** "pve.example.lan" out of "https://pve.example.lan:8006/", or the text itself when it isn't an address. */
function hostOf(baseUrl: string): string {
@@ -85,6 +86,7 @@ function IntegrationsList({ user, tabs }: { user: CurrentUser; tabs: ReactNode }
const [integrations, setIntegrations] = useState<IntegrationSummary[] | null>(null);
const [adding, setAdding] = useState(false);
const [editingIntegration, setEditingIntegration] = useState<IntegrationSummary | null>(null);
const [inspecting, setInspecting] = useState<IntegrationSummary | null>(null);
const [error, setError] = useState<string | null>(null);
const [integrationColors, setIntegrationColors] = useState<Record<string, string>>({});
const [testingId, setTestingId] = useState<number | null>(null);
@@ -184,6 +186,7 @@ function IntegrationsList({ user, tabs }: { user: CurrentUser; tabs: ReactNode }
</div>
{tabs}
<ErrorNotice error={error} />
{inspecting && <IntegrationInspector integration={inspecting} onClose={() => setInspecting(null)} />}
{editingIntegration ? (
<IntegrationEditForm
@@ -293,6 +296,11 @@ function IntegrationsList({ user, tabs }: { user: CurrentUser; tabs: ReactNode }
<button className="btn btn-sm" onClick={() => testIntegration(i)} disabled={testingId === i.id}>
{testingId === i.id ? "Testing…" : "Test"}
</button>
{i.enabled && INSPECTABLE.includes(i.type) && (
<button className="btn btn-sm" onClick={() => setInspecting(i)} title="Read it once now and see what each request got back — to check that what is shown is what is there">
Inspect
</button>
)}
<button className="btn btn-sm" onClick={() => setEditingIntegration(i)}>
Edit
</button>
+3 -3
View File
@@ -8,7 +8,7 @@ import { ErrorNotice } from "../components/Notice";
import { formatBytes } from "./settings/StorageSettings";
import { readableError } from "../utils/errors";
const KIND_NAMES: Record<ArrApp["kind"], string> = { sonarr: "Sonarr", radarr: "Radarr", prowlarr: "Prowlarr" };
const KIND_NAMES: Record<ArrApp["kind"], string> = { sonarr: "Sonarr", radarr: "Radarr", prowlarr: "Prowlarr", lidarr: "Lidarr", readarr: "Readarr" };
const QUEUE_SHOWN = 25;
function Badge({ a }: { a: ArrApp }) {
@@ -214,7 +214,7 @@ export default function Media() {
<>
<h2 className="page-title">Media managers</h2>
<p className="text-secondary">
Sonarr, Radarr and Prowlarr, read every few minutes (see <Link to="/integrations">Integrations</Link>) — nothing is searched, grabbed or changed. <strong>What an application says is wrong with itself</strong>, <strong>downloads stuck for two hours</strong> and{" "}
Sonarr, Radarr, Prowlarr, Lidarr and Readarr, read every few minutes (see <Link to="/integrations">Integrations</Link>) — nothing is searched, grabbed or changed. <strong>What an application says is wrong with itself</strong>, <strong>downloads stuck for two hours</strong> and{" "}
<strong>a disk nearly full</strong> are alerts — see <Link to="/alerts">Alerts</Link>.
</p>
<ErrorNotice error={error} />
@@ -222,7 +222,7 @@ export default function Media() {
{data && data.length === 0 && (
<div className="card">
<div className="card-body">
<EmptyState title="No Sonarr, Radarr or Prowlarr connected" hint="Add one under Integrations with its address and API key (Settings → General → Security → API Key in the application)." />
<EmptyState title="No media manager connected" hint="Add one under Integrations with its address and API key (Settings → General → Security → API Key in the application)." />
</div>
</div>
)}
+187
View File
@@ -0,0 +1,187 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type AppVersions, type CurrentUser } from "../api/client";
import EmptyState from "../components/EmptyState";
import TimeAgo from "../components/TimeAgo";
import { BlockSkeleton } from "../components/Skeleton";
import { ErrorNotice } from "../components/Notice";
import { readableError } from "../utils/errors";
import { toast } from "../utils/toast";
type Row = AppVersions["rows"][number];
const LAG: Record<Row["lag"], { text: string; badge: string }> = {
same: { text: "Up to date", badge: "bg-green-lt text-green" },
patch: { text: "A patch behind", badge: "bg-blue-lt text-blue" },
minor: { text: "A minor update behind", badge: "bg-yellow-lt text-yellow" },
major: { text: "A major version behind", badge: "bg-red-lt text-red" },
ahead: { text: "Ahead of the newest release", badge: "bg-secondary-lt text-secondary" },
unknown: { text: "Not compared", badge: "bg-secondary-lt text-secondary" },
};
const ORDER: Record<Row["lag"], number> = { major: 0, minor: 1, patch: 2, unknown: 3, ahead: 4, same: 5 };
/** What each connected application runs, against the newest release of it — the lookup is switched on here, and is the only thing this app asks of an address of its own choosing. */
export default function Versions({ user }: { user: CurrentUser }) {
const isAdmin = user.role === "admin";
const [data, setData] = useState<AppVersions | null>(null);
const [error, setError] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
const [days, setDays] = useState("0");
const adopt = (d: AppVersions) => {
setData(d);
setDays(String(d.alertAfterDays));
setError(null);
};
useEffect(() => {
api.versions
.get()
.then(adopt)
.catch((err) => setError(readableError(err)));
}, []);
async function save(enabled: boolean, alertAfterDays: number) {
setBusy(true);
try {
adopt(await api.versions.save({ enabled, alertAfterDays }));
toast.success(enabled ? "Saved." : "Switched off.");
} catch (err) {
toast.error(readableError(err));
} finally {
setBusy(false);
}
}
async function refresh() {
setBusy(true);
try {
const r = await api.versions.refresh();
adopt(r);
toast[r.result.failed > 0 ? "error" : "success"](r.result.failed > 0 ? `${r.result.failed} could not be looked up — see the list.` : `Looked up ${r.result.checked}.`);
} catch (err) {
toast.error(readableError(err));
} finally {
setBusy(false);
}
}
const rows = [...(data?.rows ?? [])].sort((a, b) => ORDER[a.lag] - ORDER[b.lag] || a.label.localeCompare(b.label));
const behind = rows.filter((r) => r.lag === "patch" || r.lag === "minor" || r.lag === "major").length;
return (
<>
<h2 className="page-title">App versions</h2>
<p className="text-secondary">
The version each connected application runs — as it was last read (see <Link to="/integrations">Integrations</Link>) — against the newest release of it. It looks the newest ones up on GitHub once a day; <strong>that is the only thing this app asks of an address that is not yours</strong>, so it is switched
off until you switch it on. Proxmox, Synology and the rest, which have no release to compare with, are not listed.
</p>
<ErrorNotice error={error} />
{!data && !error && <BlockSkeleton lines={4} />}
{data && (
<>
<div className="card mb-3">
<div className="card-body">
<label className="form-check mb-2">
<input type="checkbox" className="form-check-input" checked={data.enabled} disabled={!isAdmin || busy} onChange={(e) => void save(e.target.checked, Number(days) || 0)} />
<span className="form-check-label">
Look up the newest releases
<span className="form-hint d-block">
Asks <code>api.github.com</code> for the newest release of each application you have connected — its name, nothing about you or your systems. An administrator can switch this.
</span>
</span>
</label>
<div className="d-flex flex-wrap align-items-center gap-2">
<label htmlFor="alert-after">Warn when a newer release has been out for</label>
<input
id="alert-after"
className="form-control form-control-sm"
style={{ width: 80 }}
inputMode="numeric"
value={days}
disabled={!isAdmin || busy || !data.enabled}
onChange={(e) => setDays(e.target.value.replace(/[^0-9]/g, ""))}
onBlur={() => Number(days) !== data.alertAfterDays && void save(data.enabled, Math.min(365, Number(days) || 0))}
/>
<span>days (0 = never)</span>
{isAdmin && data.enabled && (
<button className="btn btn-sm ms-auto" disabled={busy} onClick={() => void refresh()}>
{busy ? "Looking…" : "Look up now"}
</button>
)}
</div>
<div className="text-secondary small mt-2">
{data.enabled ? (data.lastCheckedAt ? <>Last looked up <TimeAgo value={data.lastCheckedAt} />.</> : "Not looked up yet — it is done a few minutes after it is switched on.") : "Switched off."} A warning is raised under <Link to="/alerts">Alerts</Link> only with a number of days above 0.
</div>
</div>
</div>
{rows.length === 0 ? (
<div className="card">
<div className="card-body">
<EmptyState title="No versions known yet" hint="An application's version is known once its integration has been read: Sonarr, Radarr, Prowlarr, Lidarr, Readarr, AdGuard Home, Grafana, Jellyfin, Immich, Paperless-ngx, Nextcloud, NetBox, Authentik and Prometheus are compared." />
</div>
</div>
) : (
<div className="card">
<div className="card-header">
<h3 className="card-title">
{rows.length} {rows.length === 1 ? "application" : "applications"}
{data.enabled ? `, ${behind === 0 ? "none behind" : `${behind} behind`}` : ""}
</h3>
</div>
<div className="table-responsive">
<table className="table table-vcenter card-table">
<thead>
<tr>
<th>Application</th>
<th>Running</th>
<th>Newest release</th>
<th>Compared</th>
</tr>
</thead>
<tbody>
{rows.map((r) => (
<tr key={r.integrationId}>
<td>
<strong>{r.label}</strong>
<div className="text-secondary small">{r.name}</div>
</td>
<td>
<code>{r.running}</code>
</td>
<td>
{r.latest ? (
<>
{r.latest.url ? (
<a href={r.latest.url} target="_blank" rel="noopener noreferrer">
<code>{r.latest.tag}</code>
</a>
) : (
<code>{r.latest.tag}</code>
)}
{r.latest.publishedAt && (
<div className="text-secondary small">
out <TimeAgo value={r.latest.publishedAt} />
</div>
)}
</>
) : (
<span className="text-secondary">{data.enabled ? "not known yet" : "—"}</span>
)}
{r.lookupError && <div className="text-yellow small">{r.lookupError}</div>}
</td>
<td>
<span className={`badge ${LAG[r.lag].badge}`}>{LAG[r.lag].text}</span>
{r.daysOut !== null && <div className="text-secondary small">{r.daysOut === 0 ? "a newer one came out today" : r.daysOut === 1 ? "a newer one has been out a day" : `a newer one has been out ${r.daysOut} days`}</div>}
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)}
</>
)}
</>
);
}
+58
View File
@@ -0,0 +1,58 @@
import type { AlertCategory, AlertSeverity } from "../api/client";
import { kindWords } from "./alertKinds";
export type GroupBy = "none" | "source" | "category" | "kind";
export const GROUP_BY_LABELS: Record<GroupBy, string> = { none: "Not grouped", source: "Group by source", category: "Group by kind", kind: "Group by type of alert" };
/** The line above a group of alerts on the Alerts page. */
export interface AlertGroup {
isHeader: true;
id: string;
label: string;
count: number;
critical: number;
warning: number;
info: number;
silenced: number;
/** The alerts in the group that can be picked (those not held back). */
pickable: string[];
folded: boolean;
}
interface Groupable {
id: string;
severity: AlertSeverity;
silenced: boolean;
source: string;
category: AlertCategory;
kind: string;
}
const SEVERITY_RANK: Record<AlertSeverity, number> = { critical: 0, warning: 1, info: 2 };
/**
* Pure: the alerts in groups — each group a header (how many, how serious, how many are held back) and then its alerts, unless the group is folded. The worst group comes first (then the
* biggest, then by name); inside a group the alerts keep the order they were given in. `categoryLabel` says what a category is called.
*/
export function groupAlerts<T extends Groupable>(alerts: T[], by: GroupBy, folded: ReadonlySet<string>, categoryLabel: (c: AlertCategory) => string): (T | AlertGroup)[] {
if (by === "none") return alerts;
const keyOf = (a: T) => (by === "source" ? a.source : by === "category" ? categoryLabel(a.category) : kindWords(a.kind));
const groups = new Map<string, T[]>();
for (const a of alerts) groups.set(keyOf(a), [...(groups.get(keyOf(a)) ?? []), a]);
const stat = (items: T[]) => {
const active = items.filter((a) => !a.silenced);
return { critical: active.filter((a) => a.severity === "critical").length, warning: active.filter((a) => a.severity === "warning").length, info: active.filter((a) => a.severity === "info").length };
};
const worst = (items: T[]) => Math.min(3, ...items.filter((a) => !a.silenced).map((a) => SEVERITY_RANK[a.severity]));
const out: (T | AlertGroup)[] = [];
for (const [label, items] of [...groups.entries()].sort((a, b) => worst(a[1]) - worst(b[1]) || b[1].length - a[1].length || a[0].localeCompare(b[0]))) {
const id = `${by}:${label}`;
const isFolded = folded.has(id);
out.push({ isHeader: true, id, label, count: items.length, ...stat(items), silenced: items.filter((a) => a.silenced).length, pickable: items.filter((a) => !a.silenced).map((a) => a.id), folded: isFolded });
if (!isFolded) out.push(...items);
}
return out;
}
export const isGroup = (x: unknown): x is AlertGroup => typeof x === "object" && x !== null && (x as { isHeader?: boolean }).isHeader === true;
+36
View File
@@ -0,0 +1,36 @@
/** How a kind of alert reads in a sentence; any kind not listed is its own name with the dashes taken out. */
const KIND_WORDS: Record<string, string> = {
offline: "a server that stopped reporting",
disk: "a disk filling up",
"failed-units": "failed services",
smart: "a disk reporting trouble",
zfs: "a ZFS pool in trouble",
"docker-vuln": "critical vulnerabilities in Docker images",
"docker-vuln-high": "many high vulnerabilities in Docker images",
"container-restarting": "a container that keeps restarting",
"container-unhealthy": "an unhealthy container",
"container-stopped": "a container that stopped",
"hetzner-off": "a Hetzner server that is off",
"hetzner-traffic": "a Hetzner traffic quota nearly used",
"hetzner-forecast": "a Hetzner traffic quota the month will pass",
"hetzner-backup": "a Hetzner backup that is late",
"hetzner-lb": "an unhealthy Hetzner load balancer",
"hetzner-cert": "a Hetzner certificate about to end",
"hetzner-fip": "a Hetzner floating IP pointing at nothing",
"fragnet-backup": "a game server backup that is late",
"fragnet-disk": "a game server disk filling up",
"fragnet-memory": "a game server's memory running out",
"sonarr-health": "Sonarr reporting a problem",
"sonarr-queue": "stuck downloads in Sonarr",
"radarr-health": "Radarr reporting a problem",
"radarr-queue": "stuck downloads in Radarr",
"lidarr-health": "Lidarr reporting a problem",
"lidarr-queue": "stuck downloads in Lidarr",
"readarr-health": "Readarr reporting a problem",
"readarr-queue": "stuck downloads in Readarr",
"prowlarr-health": "Prowlarr reporting a problem",
"speedtest-slow": "a slow internet line",
"speedtest-failing": "failing speed tests",
};
export const kindWords = (kind: string): string => KIND_WORDS[kind] ?? `${kind.replace(/[-_]+/g, " ")} alerts`;
+8 -1
View File
@@ -32,6 +32,8 @@ export const TYPE_LABELS: Record<IntegrationType, string> = {
prowlarr: "Prowlarr",
adguard: "AdGuard Home",
grafana: "Grafana",
lidarr: "Lidarr",
readarr: "Readarr",
};
/** The page each kind of integration gets once it is connected. */
@@ -66,18 +68,23 @@ export const TYPE_PAGES: Record<IntegrationType, string> = {
prowlarr: "/media",
adguard: "/adguard",
grafana: "/grafana",
lidarr: "/media",
readarr: "/media",
};
/** The kinds of integration grouped the way the sidebar groups their pages, in the same order. */
export const TYPE_GROUPS: { id: string; label: string; types: IntegrationType[] }[] = [
{ id: "infrastructure", label: "Infrastructure", types: ["proxmox", "synology", "dockhand", "hetzner", "fragnet", "tailscale"] },
{ id: "apps", label: "Apps", types: ["homeassistant", "jellyfin", "sonarr", "radarr", "prowlarr", "immich", "paperless", "nextcloud", "authentik"] },
{ id: "apps", label: "Apps", types: ["homeassistant", "jellyfin", "sonarr", "radarr", "lidarr", "readarr", "prowlarr", "immich", "paperless", "nextcloud", "authentik"] },
{ id: "backups", label: "Backups", types: ["pbs"] },
{ id: "network", label: "Network", types: ["unifi", "npm", "phpipam", "netbox", "adguard"] },
{ id: "monitoring", label: "Monitoring", types: ["uptimekuma", "prometheus", "grafana", "ups", "speedtest"] },
{ id: "automation", label: "Automation", types: ["semaphore", "gitea", "osticket", "n8n"] },
];
/** The kinds whose reader can be inspected (Settings → Integrations → Check what can be read): the ones that read through the shared HTTP helper and have a reader to run. */
export const INSPECTABLE: IntegrationType[] = ["authentik", "immich", "jellyfin", "netbox", "nextcloud", "paperless", "prometheus", "hetzner", "speedtest", "fragnet", "sonarr", "radarr", "prowlarr", "lidarr", "readarr", "adguard", "grafana"];
/** The group a kind belongs to; a kind nobody has placed yet falls in "Other" rather than vanishing. */
export function groupOfType(type: IntegrationType): { id: string; label: string } {
return TYPE_GROUPS.find((g) => g.types.includes(type)) ?? { id: "other", label: "Other" };