Sonarr/Radarr/Prowlarr, Hetzner load balancers/floating IPs/certificates, traffic forecast

New integration kinds sonarr, radarr and prowlarr (shared adapter and sync, page under
Apps -> Media managers): own health findings, stuck downloads, nearly full disks.
Hetzner now reads load balancers (target health), floating IPs and certificates, includes
them in the cost estimate, and forecasts the month's traffic against the quota.
Migrations 0072 and 0073; docs, metrics 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-27 20:04:55 +01:00
1 parent 9a3d5c466a
commit d9083adb5b
38 files changed
+18374 -42

No files matched your search

+232
View File
@@ -0,0 +1,232 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type ArrApp } from "../api/client";
import EmptyState from "../components/EmptyState";
import TimeAgo from "../components/TimeAgo";
import { BlockSkeleton } from "../components/Skeleton";
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 QUEUE_SHOWN = 25;
function Badge({ a }: { a: ArrApp }) {
if (!a.enabled) return <span className="badge bg-secondary-lt text-secondary">Off</span>;
if (!a.state) return <span className="badge bg-secondary-lt text-secondary">Not read yet</span>;
if (!a.fresh) return <span className="badge bg-yellow-lt text-yellow">Can&rsquo;t be read</span>;
if (a.problems.some((x) => x.severity === "critical")) return <span className="badge bg-red-lt text-red">Needs a look</span>;
if (a.problems.length > 0) return <span className="badge bg-yellow-lt text-yellow">Needs a look</span>;
return <span className="badge bg-green-lt text-green">In order</span>;
}
function Tile({ label, value, sub, warn }: { label: string; value: string; sub?: string | null; warn?: boolean }) {
return (
<div className="col-6 col-lg-3">
<div className="card card-sm h-100">
<div className="card-body">
<div className="text-secondary small">{label}</div>
<div className={`h2 mb-0 ${warn ? "text-yellow" : ""}`}>{value}</div>
{sub && <div className="text-secondary small">{sub}</div>}
</div>
</div>
</div>
);
}
function Card({ a }: { a: ArrApp }) {
const s = a.state;
const stuck = new Set(s?.stuck ?? []);
const queue = s?.queue ?? null;
const items = queue ? [...queue.items].sort((x, y) => Number(stuck.has(y.id)) - Number(stuck.has(x.id)) || Date.parse(x.added ?? "") - Date.parse(y.added ?? "")) : [];
const findings = (s?.health ?? []).filter((h) => h.type === "warning" || h.type === "error");
const notices = (s?.health ?? []).filter((h) => h.type === "notice");
return (
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">
{a.name} <span className="text-secondary fw-normal">{KIND_NAMES[a.kind]}{s?.version ? ` ${s.version}` : ""}</span> <Badge a={a} />
</h3>
<div className="card-actions text-secondary small">{a.status ? <>read <TimeAgo value={a.status.at} /></> : "not read yet"}</div>
</div>
<div className="card-body">
{a.status && !a.status.ok && <div className="text-yellow mb-2">The last attempt to read it failed: {a.status.error ?? "no answer"}.</div>}
{a.problems.length > 0 && (
<ul className="mb-3">
{a.problems.map((x) => (
<li key={x.key} className={x.severity === "critical" ? "text-red" : ""}>
{x.message}
</li>
))}
</ul>
)}
{s && (
<>
<div className="row g-3 mb-3">
{a.kind !== "prowlarr" && (
<>
<Tile label="Download queue" value={queue ? String(queue.total) : "—"} sub={queue ? (stuck.size > 0 ? `${stuck.size} stuck` : "nothing stuck") : "could not be read"} warn={stuck.size > 0} />
<Tile label="Wanted, no file yet" value={s.missing === null ? "—" : String(s.missing)} sub="monitored items" />
</>
)}
{a.kind === "prowlarr" && (
<>
<Tile label="Indexers" value={s.indexers ? String(s.indexers.length) : "—"} sub={s.indexers ? `${s.indexers.filter((i) => i.enabled).length} switched on` : "could not be read"} />
<Tile label="Failing" value={s.indexers ? String(s.indexers.filter((i) => i.disabledTill && Date.parse(i.disabledTill) > Date.now()).length) : "—"} sub="switched off after failures" warn={!!s.indexers?.some((i) => i.disabledTill && Date.parse(i.disabledTill) > Date.now())} />
</>
)}
<Tile label="Its own findings" value={String(findings.length)} sub={notices.length > 0 ? `and ${notices.length} notice${notices.length === 1 ? "" : "s"}` : "warnings and errors"} warn={findings.length > 0} />
<Tile label="Disks" value={s.disks ? String(s.disks.length) : "—"} sub={s.disks ? (s.disks.length > 0 ? `${formatBytes(Math.min(...s.disks.map((d) => d.free)))} free on the fullest` : "none reported") : "could not be read"} />
</div>
{(findings.length > 0 || notices.length > 0) && (
<>
<h4>What {KIND_NAMES[a.kind]} says</h4>
<ul>
{[...findings, ...notices].map((h, i) => (
<li key={`${h.source}-${i}`}>
<span className={`badge ${h.type === "error" ? "bg-red-lt text-red" : h.type === "warning" ? "bg-yellow-lt text-yellow" : "bg-blue-lt text-blue"}`}>{h.type}</span> {h.message}
</li>
))}
</ul>
</>
)}
{s.disks && s.disks.length > 0 && (
<div className="mb-3">
<h4>Disks</h4>
{s.disks.map((d) => {
const free = d.total > 0 ? d.free / d.total : 1;
return (
<div key={d.path} className="mb-1" style={{ maxWidth: 520 }}>
<div className="progress progress-sm">
<div className={`progress-bar ${free < 0.05 ? "bg-red" : free < 0.1 ? "bg-yellow" : "bg-green"}`} style={{ width: `${Math.min(100, (1 - free) * 100)}%` }} />
</div>
<div className="small text-secondary">
<code>{d.path}</code> {formatBytes(d.free)} free of {formatBytes(d.total)} ({Math.floor(free * 100)}%)
</div>
</div>
);
})}
</div>
)}
{queue && queue.total > 0 && (
<>
<h4>Download queue</h4>
<div className="table-responsive">
<table className="table table-vcenter card-table">
<thead>
<tr>
<th>Title</th>
<th>State</th>
<th>Progress</th>
<th>In the queue</th>
<th>Client</th>
</tr>
</thead>
<tbody>
{items.slice(0, QUEUE_SHOWN).map((i) => {
const done = i.size && i.size > 0 && i.sizeLeft !== null ? Math.round(((i.size - i.sizeLeft) / i.size) * 100) : null;
const isStuck = stuck.has(i.id);
return (
<tr key={i.id}>
<td className="text-break">
{i.title}
{i.messages.map((m) => (
<div key={m} className={`small ${isStuck ? "text-red" : "text-yellow"}`}>
{m}
</div>
))}
</td>
<td>
{isStuck ? <span className="badge bg-red-lt text-red">stuck</span> : i.tracked === "warning" || i.tracked === "error" ? <span className="badge bg-yellow-lt text-yellow">{i.tracked}</span> : <span className="badge bg-secondary-lt text-secondary">{i.status}</span>}
{i.state && i.state !== "downloading" && <div className="small text-secondary">{i.state}</div>}
</td>
<td style={{ minWidth: 120 }}>
{done === null ? (
<span className="text-secondary">—</span>
) : (
<>
<div className="progress progress-sm">
<div className="progress-bar" style={{ width: `${done}%` }} />
</div>
<div className="small text-secondary">
{done}%{i.size ? ` of ${formatBytes(i.size)}` : ""}
</div>
</>
)}
</td>
<td className="text-secondary">
<TimeAgo value={i.added} />
</td>
<td className="text-secondary text-break">
{i.client ?? "—"}
{i.indexer && <div className="small">{i.indexer}</div>}
</td>
</tr>
);
})}
</tbody>
</table>
</div>
{queue.total > QUEUE_SHOWN && <div className="text-secondary small">{queue.total - QUEUE_SHOWN} more are in the queue (the stuck ones are listed first).</div>}
</>
)}
{s.indexers && s.indexers.length > 0 && (
<>
<h4 className="mt-3">Indexers</h4>
<ul className="mb-0">
{s.indexers.map((i) => {
const off = i.disabledTill !== null && Date.parse(i.disabledTill) > Date.now();
return (
<li key={i.id}>
<strong>{i.name}</strong> {i.protocol && <span className="text-secondary small">{i.protocol}</span>}{" "}
{!i.enabled ? <span className="badge bg-secondary-lt text-secondary">off</span> : off ? <span className="badge bg-red-lt text-red">failing, tried again <TimeAgo value={i.disabledTill} /></span> : <span className="badge bg-green-lt text-green">working</span>}
</li>
);
})}
</ul>
</>
)}
</>
)}
</div>
</div>
);
}
/** Sonarr, Radarr and Prowlarr: what each says is wrong, the downloads that are stuck, the disks they fill and the indexers that have failed. */
export default function Media() {
const [data, setData] = useState<ArrApp[] | null>(null);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const load = () =>
api.arr
.list()
.then((r) => {
setData(r.apps);
setError(null);
})
.catch((err) => setError(readableError(err)));
void load();
const t = setInterval(load, 60_000);
return () => clearInterval(t);
}, []);
return (
<>
<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{" "}
<strong>a disk nearly full</strong> are alerts — see <Link to="/alerts">Alerts</Link>.
</p>
<ErrorNotice error={error} />
{!data && !error && <BlockSkeleton lines={4} />}
{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)." />
</div>
</div>
)}
{data?.map((a) => <Card key={a.id} a={a} />)}
</>
);
}