Add qBittorrent and SABnzbd: a Download clients page with stuck, disconnected, paused and full-disk alerts

Each client is read every five minutes (read-only; qBittorrent's sign-in is the only POST): speed, queue and item states, network connection or paused queue, free space, SABnzbd's failures and warnings. Shared adapter, sync service, download_state table, /api/downloads, metrics and docs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-04 23:13:03 +01:00
1 parent c7775e5dd9
commit 7618bf0f0a
32 files changed
+10715 -12

No files matched your search

+2
View File
@@ -22,6 +22,7 @@ import Nextcloud from "./pages/Nextcloud";
import Hetzner from "./pages/Hetzner";
import GameServers from "./pages/GameServers";
import Media from "./pages/Media";
import Downloads from "./pages/Downloads";
import AdguardHome from "./pages/AdguardHome";
import TechnitiumDns from "./pages/TechnitiumDns";
import Grafana from "./pages/Grafana";
@@ -185,6 +186,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="/downloads" element={<Downloads />} />
<Route path="/versions" element={<Versions user={user} />} />
<Route path="/adguard" element={<AdguardHome />} />
<Route path="/technitium" element={<TechnitiumDns />} />
+57 -1
View File
@@ -1543,6 +1543,59 @@ export interface ArrApp {
problems: { key: string; message: string; severity: "warning" | "critical" }[];
}
export type DownloadState = "downloading" | "queued" | "waiting" | "stalled" | "paused" | "processing" | "error" | "seeding" | "completed" | "failed" | "other";
export interface DownloadItem {
id: string;
name: string;
state: DownloadState;
/** The client's own word for it ("stalledDL", "Verifying" …). */
rawState: string;
/** 0 to 1. */
progress: number | null;
size: number | null;
left: number | null;
speed: number | null;
eta: number | null;
addedAt: string | null;
/** The last time anything moved; for a failed download, when it failed. */
activityAt: string | null;
category: string | null;
message: string | null;
}
/** One qBittorrent or SABnzbd (an integration of that type), as the download clients page shows it. */
export interface DownloadClient {
id: number;
kind: "qbittorrent" | "sabnzbd";
name: string;
enabled: boolean;
url: string;
status: { at: string; ok: boolean; error: string | null } | null;
fresh: boolean;
state: {
version: string | null;
speedDown: number | null;
speedUp: number | null;
paused: boolean;
connection: "connected" | "firewalled" | "disconnected" | null;
counts: Record<DownloadState, number>;
total: number;
/** The items that are not finished and idle (at most 100). */
items: DownloadItem[];
/** Failed downloads (SABnzbd); null when none were reported. */
failed: DownloadItem[] | null;
disks: { label: string; free: number; total: number | null }[] | null;
warnings: { count: number; recent: string[] } | null;
since: { pausedSince: string | null; disconnectedSince: string | null; idleSince: string | null };
updatedAt: string;
/** The ids of the items that are stuck, and of the downloads that failed in the last day. */
stuck: string[];
failedRecent: string[];
} | null;
problems: { key: string; message: string; severity: "warning" | "critical" }[];
}
/** One AdGuard Home (an integration of type adguard), as its page shows it. */
export interface AdguardInstance {
id: number;
@@ -2928,7 +2981,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" | "technitium" | "grafana" | "lidarr" | "readarr";
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" | "technitium" | "grafana" | "lidarr" | "readarr" | "qbittorrent" | "sabnzbd";
export interface IntegrationField {
key: string;
@@ -3547,6 +3600,9 @@ export const api = {
arr: {
list: () => request<{ apps: ArrApp[] }>("/api/arr"),
},
downloads: {
list: () => request<{ clients: DownloadClient[] }>("/api/downloads"),
},
fragnet: {
list: () => request<{ accounts: FragnetAccount[] }>("/api/fragnet"),
power: (integrationId: number, serverId: string, signal: FragnetSignal) => request<void>(`/api/fragnet/${integrationId}/servers/${serverId}/power`, { method: "POST", body: JSON.stringify({ signal }) }),
+2
View File
@@ -39,6 +39,8 @@ const TYPE_LABELS: Record<string, string> = {
grafana: "Grafana",
lidarr: "Lidarr",
readarr: "Readarr",
qbittorrent: "qBittorrent",
sabnzbd: "SABnzbd",
};
export type WallLevel = "critical" | "warning" | "ok" | "unsure";
+2
View File
@@ -43,6 +43,7 @@ import {
IconCoin,
IconBooks,
IconDownload,
IconCloudDownload,
IconBox,
IconHeartbeat,
IconGitCommit,
@@ -113,6 +114,7 @@ export const NAV: NavEntry[] = [
{ to: "/home-assistant", label: "Home Assistant", icon: <IconHome2 size={20} /> },
{ to: "/jellyfin", label: "Jellyfin", icon: <IconMovie size={20} /> },
{ to: "/media", label: "Media managers", icon: <IconDeviceTv size={20} /> },
{ to: "/downloads", label: "Download clients", icon: <IconCloudDownload size={20} /> },
{ to: "/immich", label: "Immich", icon: <IconPhoto size={20} /> },
{ to: "/paperless", label: "Paperless", icon: <IconFileText size={20} /> },
{ to: "/nextcloud", label: "Nextcloud", icon: <IconCloud size={20} /> },
+273
View File
@@ -0,0 +1,273 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type DownloadClient, type DownloadItem, type DownloadState } 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<DownloadClient["kind"], string> = { qbittorrent: "qBittorrent", sabnzbd: "SABnzbd" };
const SHOWN = 25;
const STATE_BADGE: Record<DownloadState, string> = {
downloading: "bg-blue-lt text-blue",
queued: "bg-secondary-lt text-secondary",
waiting: "bg-secondary-lt text-secondary",
stalled: "bg-yellow-lt text-yellow",
paused: "bg-secondary-lt text-secondary",
processing: "bg-azure-lt text-azure",
error: "bg-red-lt text-red",
seeding: "bg-green-lt text-green",
completed: "bg-green-lt text-green",
failed: "bg-red-lt text-red",
other: "bg-secondary-lt text-secondary",
};
const speedText = (n: number | null): string => (n === null ? "—" : `${formatBytes(n)}/s`);
/** "2 h 5 min", "14 min", "40 s". */
function durationText(seconds: number): string {
if (seconds >= 86400) return `${Math.floor(seconds / 86400)} d ${Math.floor((seconds % 86400) / 3600)} h`;
if (seconds >= 3600) return `${Math.floor(seconds / 3600)} h ${Math.floor((seconds % 3600) / 60)} min`;
if (seconds >= 60) return `${Math.round(seconds / 60)} min`;
return `${Math.max(1, Math.round(seconds))} s`;
}
function Badge({ c }: { c: DownloadClient }) {
if (!c.enabled) return <span className="badge bg-secondary-lt text-secondary">Off</span>;
if (!c.state) return <span className="badge bg-secondary-lt text-secondary">Not read yet</span>;
if (!c.fresh) return <span className="badge bg-yellow-lt text-yellow">Can&rsquo;t be read</span>;
if (c.problems.some((x) => x.severity === "critical")) return <span className="badge bg-red-lt text-red">Needs a look</span>;
if (c.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 ItemsTable({ items, stuck }: { items: DownloadItem[]; stuck: Set<string> }) {
return (
<>
<div className="table-responsive">
<table className="table table-vcenter card-table">
<thead>
<tr>
<th>Name</th>
<th>State</th>
<th>Progress</th>
<th>Speed</th>
<th>Left</th>
<th>Category</th>
</tr>
</thead>
<tbody>
{items.slice(0, SHOWN).map((i) => {
const pct = i.progress === null ? null : Math.round(i.progress * 100);
const isStuck = stuck.has(i.id);
return (
<tr key={i.id}>
<td className="text-break">{i.name}</td>
<td>
{isStuck ? <span className="badge bg-red-lt text-red">stuck</span> : <span className={`badge ${STATE_BADGE[i.state]}`}>{i.state}</span>}
{i.rawState.toLowerCase() !== i.state && <div className="small text-secondary">{i.rawState}</div>}
{isStuck && i.state === "stalled" && i.activityAt && (
<div className="small text-red">
nothing moved <TimeAgo value={i.activityAt} />
</div>
)}
</td>
<td style={{ minWidth: 120 }}>
{pct === null ? (
<span className="text-secondary">—</span>
) : (
<>
<div className="progress progress-sm">
<div className="progress-bar" style={{ width: `${pct}%` }} />
</div>
<div className="small text-secondary">
{pct}%{i.size ? ` of ${formatBytes(i.size)}` : ""}
</div>
</>
)}
</td>
<td className="text-secondary">{i.speed ? speedText(i.speed) : "—"}</td>
<td className="text-secondary">
{i.left !== null && i.left > 0 ? formatBytes(i.left) : "—"}
{i.eta !== null && <div className="small">{durationText(i.eta)}</div>}
</td>
<td className="text-secondary">{i.category ?? "—"}</td>
</tr>
);
})}
</tbody>
</table>
</div>
{items.length > SHOWN && <div className="text-secondary small">{items.length - SHOWN} more are listed by the client (the ones needing a look first).</div>}
</>
);
}
function Card({ c }: { c: DownloadClient }) {
const s = c.state;
const stuck = new Set(s?.stuck ?? []);
const failedRecent = new Set(s?.failedRecent ?? []);
const failed = (s?.failed ?? []).filter((f) => failedRecent.has(f.id));
const pending = s ? s.total - s.counts.seeding - s.counts.completed - s.counts.failed : 0;
const fullest = s?.disks && s.disks.length > 0 ? s.disks.reduce((a, b) => (a.free < b.free ? a : b)) : null;
return (
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">
{c.name} <span className="text-secondary fw-normal">{KIND_NAMES[c.kind]}{s?.version ? ` ${s.version}` : ""}</span> <Badge c={c} />
</h3>
<div className="card-actions text-secondary small">{c.status ? <>read <TimeAgo value={c.status.at} /></> : "not read yet"}</div>
</div>
<div className="card-body">
{c.status && !c.status.ok && <div className="text-yellow mb-2">The last attempt to read it failed: {c.status.error ?? "no answer"}.</div>}
{c.problems.length > 0 && (
<ul className="mb-3">
{c.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">
<Tile label="Downloading" value={speedText(s.speedDown)} sub={s.speedUp !== null ? `uploading ${speedText(s.speedUp)}` : null} />
<Tile
label={c.kind === "sabnzbd" ? "Queue" : "Not finished"}
value={String(pending)}
sub={[`${s.counts.downloading} downloading`, `${s.counts.queued + s.counts.waiting} waiting`, s.counts.stalled > 0 ? `${s.counts.stalled} stalled` : null, s.counts.error > 0 ? `${s.counts.error} in error` : null, c.kind === "qbittorrent" ? `${s.counts.seeding} seeding` : null].filter(Boolean).join(", ")}
/>
{c.kind === "qbittorrent" ? (
<Tile label="Stuck" value={String(stuck.size)} sub={stuck.size > 0 ? "in error, or nothing moving for a day" : "nothing stuck"} warn={stuck.size > 0} />
) : (
<Tile label="Failed in the last day" value={s.failed === null ? "—" : String(failedRecent.size)} sub={s.failed === null ? "could not be read" : null} warn={failedRecent.size > 0} />
)}
{c.kind === "qbittorrent" ? (
<Tile
label="Network"
value={s.connection === null ? "—" : s.connection}
sub={s.connection === "firewalled" ? "no incoming connections — it still works" : s.connection === "disconnected" ? "no peers or DHT" : null}
warn={s.connection === "disconnected"}
/>
) : (
<Tile label="Queue is" value={s.paused ? "Paused" : "Running"} sub={s.paused && s.since.pausedSince ? `for ${durationText((Date.now() - Date.parse(s.since.pausedSince)) / 1000)}` : null} warn={s.paused && pending > 0} />
)}
{fullest && <Tile label="Free space" value={formatBytes(fullest.free)} sub={fullest.total ? `of ${formatBytes(fullest.total)} (${fullest.label.toLowerCase()})` : fullest.label.toLowerCase()} warn={fullest.total ? fullest.free / fullest.total < 0.1 : fullest.free < 20 * 1024 ** 3} />}
</div>
{s.disks && s.disks.some((d) => d.total) && (
<div className="mb-3">
<h4>Disks</h4>
{s.disks
.filter((d) => d.total)
.map((d) => {
const free = d.total ? d.free / d.total : 1;
return (
<div key={d.label} 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">
{d.label}: {formatBytes(d.free)} free of {formatBytes(d.total!)} ({Math.floor(free * 100)}%)
</div>
</div>
);
})}
</div>
)}
{s.items.length > 0 && (
<>
<h4>{c.kind === "sabnzbd" ? "Queue" : "Not finished"}</h4>
<ItemsTable items={s.items} stuck={stuck} />
{s.counts.seeding + s.counts.completed > 0 && <div className="text-secondary small">{s.counts.seeding + s.counts.completed} more are finished and idle (seeding or stopped), and not listed.</div>}
</>
)}
{s.items.length === 0 && <div className="text-secondary">{s.total === 0 ? "Nothing in the queue." : `${s.total} item${s.total === 1 ? "" : "s"}, all finished and idle.`}</div>}
{failed.length > 0 && (
<>
<h4 className="mt-3">Failed in the last day</h4>
<ul className="mb-0">
{failed.map((f) => (
<li key={f.id} className="text-break">
{f.name} <span className="text-secondary small"><TimeAgo value={f.activityAt} /></span>
{f.message && <div className="small text-red">{f.message}</div>}
</li>
))}
</ul>
</>
)}
{s.warnings && s.warnings.count > 0 && (
<div className="mt-3">
<h4>
{KIND_NAMES[c.kind]}&rsquo;s own warnings <span className="text-secondary fw-normal small">({s.warnings.count} in its list — cleared in its own Warnings page)</span>
</h4>
<ul className="mb-0 small text-secondary">
{s.warnings.recent.map((w, i) => (
<li key={i} className="text-break">
{w}
</li>
))}
</ul>
</div>
)}
</>
)}
</div>
</div>
);
}
/** qBittorrent and SABnzbd: how fast they are going, what is in their queues and in what state, what is stuck or failed, and the room they have. */
export default function Downloads() {
const [data, setData] = useState<DownloadClient[] | null>(null);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const load = () =>
api.downloads
.list()
.then((r) => {
setData(r.clients);
setError(null);
})
.catch((err) => setError(readableError(err)));
void load();
const t = setInterval(load, 60_000);
return () => clearInterval(t);
}, []);
return (
<>
<h2 className="page-title">Download clients</h2>
<p className="text-secondary">
qBittorrent and SABnzbd, read every few minutes (see <Link to="/integrations">Integrations</Link>) — nothing is added, paused or removed. <strong>Downloads that are stuck</strong>, <strong>no connection</strong>, <strong>a queue left paused or getting nothing</strong> and{" "}
<strong>a disk nearly full</strong> are alerts — see <Link to="/alerts">Alerts</Link>. What Sonarr, Radarr and the others think of their downloads is on <Link to="/media">Media managers</Link>.
</p>
<ErrorNotice error={error} />
{!data && !error && <BlockSkeleton lines={4} />}
{data && data.length === 0 && (
<div className="card">
<div className="card-body">
<EmptyState title="No download client connected" hint="Add qBittorrent (its Web UI address, and the user name and password of the Web UI) or SABnzbd (its address and API key) under Integrations." />
</div>
</div>
)}
{data?.map((c) => <Card key={c.id} c={c} />)}
</>
);
}
+7
View File
@@ -29,6 +29,13 @@ const KIND_WORDS: Record<string, string> = {
"readarr-health": "Readarr reporting a problem",
"readarr-queue": "stuck downloads in Readarr",
"prowlarr-health": "Prowlarr reporting a problem",
"qbittorrent-stuck": "stuck torrents in qBittorrent",
"qbittorrent-connection": "qBittorrent with no connection",
"qbittorrent-disk": "a qBittorrent download disk filling up",
"sabnzbd-stuck": "stuck downloads in SABnzbd",
"sabnzbd-paused": "a SABnzbd queue left paused",
"sabnzbd-stalled": "SABnzbd downloading nothing",
"sabnzbd-disk": "a SABnzbd download disk filling up",
"speedtest-slow": "a slow internet line",
"speedtest-failing": "failing speed tests",
};
+6 -2
View File
@@ -35,6 +35,8 @@ export const TYPE_LABELS: Record<IntegrationType, string> = {
grafana: "Grafana",
lidarr: "Lidarr",
readarr: "Readarr",
qbittorrent: "qBittorrent",
sabnzbd: "SABnzbd",
};
/** The page each kind of integration gets once it is connected. */
@@ -72,12 +74,14 @@ export const TYPE_PAGES: Record<IntegrationType, string> = {
grafana: "/grafana",
lidarr: "/media",
readarr: "/media",
qbittorrent: "/downloads",
sabnzbd: "/downloads",
};
/** 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", "lidarr", "readarr", "prowlarr", "immich", "paperless", "nextcloud", "authentik"] },
{ id: "apps", label: "Apps", types: ["homeassistant", "jellyfin", "sonarr", "radarr", "lidarr", "readarr", "prowlarr", "qbittorrent", "sabnzbd", "immich", "paperless", "nextcloud", "authentik"] },
{ id: "backups", label: "Backups", types: ["pbs"] },
{ id: "network", label: "Network", types: ["unifi", "npm", "phpipam", "netbox", "adguard", "technitium"] },
{ id: "monitoring", label: "Monitoring", types: ["uptimekuma", "prometheus", "grafana", "ups", "speedtest"] },
@@ -85,7 +89,7 @@ export const TYPE_GROUPS: { id: string; label: string; types: IntegrationType[]
];
/** 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", "technitium", "grafana"];
export const INSPECTABLE: IntegrationType[] = ["authentik", "immich", "jellyfin", "netbox", "nextcloud", "paperless", "prometheus", "hetzner", "speedtest", "fragnet", "sonarr", "radarr", "prowlarr", "lidarr", "readarr", "qbittorrent", "sabnzbd", "adguard", "technitium", "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 } {