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:
1 parent
9a3d5c466a
commit
d9083adb5b
38 files changed
+18374
-42
No files matched your search
@@ -21,6 +21,7 @@ import NetBox from "./pages/NetBox";
|
||||
import Nextcloud from "./pages/Nextcloud";
|
||||
import Hetzner from "./pages/Hetzner";
|
||||
import GameServers from "./pages/GameServers";
|
||||
import Media from "./pages/Media";
|
||||
import Speedtest from "./pages/Speedtest";
|
||||
import Costs from "./pages/Costs";
|
||||
import ServiceLevels from "./pages/ServiceLevels";
|
||||
@@ -180,6 +181,7 @@ function Shelled({ user }: { user: CurrentUser }) {
|
||||
<Route path="/nextcloud" element={<Nextcloud />} />
|
||||
<Route path="/hetzner" element={<Hetzner />} />
|
||||
<Route path="/game-servers" element={<GameServers user={user} />} />
|
||||
<Route path="/media" element={<Media />} />
|
||||
<Route path="/speedtest" element={<Speedtest />} />
|
||||
<Route path="/costs" element={<Costs user={user} />} />
|
||||
<Route path="/service-levels" element={<ServiceLevels user={user} />} />
|
||||
|
||||
+84
-2
@@ -1285,6 +1285,55 @@ export interface HetznerServerInfo {
|
||||
lastRunningAt: string | null;
|
||||
statusSince: string;
|
||||
rescueSince: string | null;
|
||||
/** How the month's traffic is forecast to end; null when there is too little to say. */
|
||||
forecast?: HetznerTrafficForecast | null;
|
||||
}
|
||||
|
||||
export interface HetznerTrafficForecast {
|
||||
/** Bytes a day, the way it has been going. */
|
||||
perDay: number;
|
||||
/** What the month will have come to by its end at that rate. */
|
||||
projectedMonth: number;
|
||||
/** When the quota is passed, if that is before the month ends. */
|
||||
exhaustedAt: string | null;
|
||||
basis: "recent" | "month";
|
||||
}
|
||||
|
||||
export interface HetznerLoadBalancerInfo {
|
||||
id: number;
|
||||
name: string;
|
||||
type: string | null;
|
||||
location: string | null;
|
||||
ipv4: string | null;
|
||||
algorithm: string | null;
|
||||
services: number;
|
||||
targets: { kind: "server" | "label_selector" | "ip"; serverId: number | null; serverName: string | null; label: string | null; health: "healthy" | "unhealthy" | "unknown" }[];
|
||||
includedTraffic: number | null;
|
||||
outgoingTraffic: number | null;
|
||||
monthlyPrice: number | null;
|
||||
}
|
||||
|
||||
export interface HetznerFloatingIpInfo {
|
||||
id: number;
|
||||
name: string | null;
|
||||
ip: string;
|
||||
type: "ipv4" | "ipv6";
|
||||
serverId: number | null;
|
||||
serverName: string | null;
|
||||
location: string | null;
|
||||
description: string | null;
|
||||
}
|
||||
|
||||
export interface HetznerCertificateInfo {
|
||||
id: number;
|
||||
name: string;
|
||||
type: string;
|
||||
domains: string[];
|
||||
notValidAfter: string | null;
|
||||
issuance: string | null;
|
||||
renewal: string | null;
|
||||
error: string | null;
|
||||
usedBy: number;
|
||||
}
|
||||
|
||||
export interface HetznerProblemInfo {
|
||||
@@ -1307,7 +1356,11 @@ export interface HetznerProject {
|
||||
/** Null when the volumes could not be listed, which is not the same as none. */
|
||||
volumes: { id: number; name: string; size: number; serverId: number | null; serverName: string | null; location: string | null; status: string }[] | null;
|
||||
images: { id: number; type: "snapshot" | "backup"; description: string | null; created: string | null; sizeGb: number | null; serverId: number | null; serverName: string | null }[] | null;
|
||||
cost: { currency: string; servers: number; backups: number; volumes: number; snapshots: number; ips: number; total: number; unassignedIps: number; unpriced: number } | null;
|
||||
cost: { currency: string; servers: number; backups: number; volumes: number; snapshots: number; ips: number; loadBalancers?: number; floatingIps?: number; total: number; unassignedIps: number; unpriced: number } | null;
|
||||
/** Each of these is null when it could not be listed, which is not the same as none. */
|
||||
loadBalancers: HetznerLoadBalancerInfo[] | null;
|
||||
floatingIps: HetznerFloatingIpInfo[] | null;
|
||||
certificates: HetznerCertificateInfo[] | null;
|
||||
updatedAt: string;
|
||||
} | null;
|
||||
problems: HetznerProblemInfo[];
|
||||
@@ -1323,6 +1376,7 @@ export interface HetznerForServer {
|
||||
newestBackup: string | null;
|
||||
snapshots: number;
|
||||
problems: HetznerProblemInfo[];
|
||||
forecast: HetznerTrafficForecast | null;
|
||||
} | null;
|
||||
}
|
||||
|
||||
@@ -1375,6 +1429,31 @@ export interface FragnetAccount {
|
||||
problems: { key: string; serverId: string; message: string; severity: "warning" | "critical" }[];
|
||||
}
|
||||
|
||||
/** 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";
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
url: string;
|
||||
status: { at: string; ok: boolean; error: string | null } | null;
|
||||
fresh: boolean;
|
||||
state: {
|
||||
version: string | null;
|
||||
/** What its own checks found: type is ok, notice, warning or error. */
|
||||
health: { source: string; type: string; message: string }[];
|
||||
/** Null when it could not be read (and always for Prowlarr, which has none). */
|
||||
queue: { total: number; items: { id: number; title: string; status: string; tracked: "ok" | "warning" | "error" | null; state: string | null; messages: string[]; size: number | null; sizeLeft: number | null; added: string | null; etaAt: string | null; protocol: string | null; client: string | null; indexer: string | null }[] } | null;
|
||||
disks: { path: string; label: string | null; free: number; total: number }[] | null;
|
||||
missing: number | null;
|
||||
indexers: { id: number; name: string; enabled: boolean; protocol: string | null; disabledTill: string | null; lastFailure: string | null }[] | null;
|
||||
updatedAt: string;
|
||||
/** The ids of the queue items that are stuck. */
|
||||
stuck: number[];
|
||||
} | null;
|
||||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||||
}
|
||||
|
||||
export type FragnetSignal = "start" | "stop" | "restart" | "kill";
|
||||
|
||||
export interface CostItem {
|
||||
@@ -2495,7 +2574,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";
|
||||
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";
|
||||
|
||||
export interface IntegrationField {
|
||||
key: string;
|
||||
@@ -3090,6 +3169,9 @@ export const api = {
|
||||
list: () => request<{ speedtests: SpeedtestInfo[] }>("/api/speedtest"),
|
||||
history: (id: number, days: number) => request<SpeedtestHistory>(`/api/speedtest/${id}/history?days=${days}`),
|
||||
},
|
||||
arr: {
|
||||
list: () => request<{ apps: ArrApp[] }>("/api/arr"),
|
||||
},
|
||||
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,7 +2,7 @@ import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type HetznerForServer } from "../api/client";
|
||||
import TimeAgo from "./TimeAgo";
|
||||
import { StatusBadge, TrafficBar } from "../pages/Hetzner";
|
||||
import { ForecastText, StatusBadge, TrafficBar } from "../pages/Hetzner";
|
||||
|
||||
/** On a server's page: the Hetzner Cloud server it is (matched by address, else by name), when there is one. Nothing is shown for a server that is not at Hetzner. */
|
||||
export default function HetznerServerCard({ serverId }: { serverId: number }) {
|
||||
@@ -57,6 +57,7 @@ export default function HetznerServerCard({ serverId }: { serverId: number }) {
|
||||
<div className="col-6 col-lg-3">
|
||||
<div className="text-secondary small">Traffic this month</div>
|
||||
<TrafficBar used={s.outgoingTraffic} included={s.includedTraffic} />
|
||||
<ForecastText forecast={match.forecast} included={s.includedTraffic} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-secondary small mt-2">
|
||||
|
||||
@@ -30,6 +30,9 @@ const TYPE_LABELS: Record<string, string> = {
|
||||
hetzner: "Hetzner Cloud",
|
||||
speedtest: "Speedtest Tracker",
|
||||
fragnet: "Fragnet game servers",
|
||||
sonarr: "Sonarr",
|
||||
radarr: "Radarr",
|
||||
prowlarr: "Prowlarr",
|
||||
};
|
||||
|
||||
export type WallLevel = "critical" | "warning" | "ok" | "unsure";
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
IconCloud,
|
||||
IconBinaryTree,
|
||||
IconDeviceGamepad2,
|
||||
IconDeviceTv,
|
||||
IconServerBolt,
|
||||
IconBolt,
|
||||
IconFileText,
|
||||
@@ -109,6 +110,7 @@ export const NAV: NavEntry[] = [
|
||||
items: [
|
||||
{ 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: "/immich", label: "Immich", icon: <IconPhoto size={20} /> },
|
||||
{ to: "/paperless", label: "Paperless", icon: <IconFileText size={20} /> },
|
||||
{ to: "/nextcloud", label: "Nextcloud", icon: <IconCloud size={20} /> },
|
||||
|
||||
+111
-4
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type HetznerProject } from "../api/client";
|
||||
import { api, type HetznerProject, type HetznerTrafficForecast } from "../api/client";
|
||||
import EmptyState from "../components/EmptyState";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import { BlockSkeleton } from "../components/Skeleton";
|
||||
@@ -23,6 +23,22 @@ export function StatusBadge({ status }: { status: string }) {
|
||||
return <span className="badge bg-yellow-lt text-yellow">{status}</span>;
|
||||
}
|
||||
|
||||
const DAY_NAMES = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
||||
const dayText = (iso: string) => {
|
||||
const d = new Date(iso);
|
||||
return `${d.getUTCDate()} ${DAY_NAMES[d.getUTCMonth()]}`;
|
||||
};
|
||||
|
||||
/** What the month's traffic is forecast to come to, and when the quota goes if it is before the month ends. */
|
||||
export function ForecastText({ forecast, included }: { forecast: HetznerTrafficForecast | null | undefined; included: number | null }) {
|
||||
if (!forecast || included === null || included <= 0) return null;
|
||||
return (
|
||||
<div className={`small ${forecast.exhaustedAt ? "text-yellow" : "text-secondary"}`}>
|
||||
{forecast.exhaustedAt ? <>at this rate the quota is passed on {dayText(forecast.exhaustedAt)}</> : <>on course for {formatBytes(forecast.projectedMonth)} by the month’s end</>} · {formatBytes(forecast.perDay)} a day ({forecast.basis === "recent" ? "this week" : "the month"})
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** This month's outgoing traffic against what the server includes, as a bar that turns yellow at 80% and red at 100%. */
|
||||
export function TrafficBar({ used, included }: { used: number | null; included: number | null }) {
|
||||
if (used === null || included === null || included <= 0) return <span className="text-secondary">{used === null ? "—" : formatBytes(used)}</span>;
|
||||
@@ -76,6 +92,7 @@ function ServerRow({ s }: { s: NonNullable<HetznerProject["state"]>["servers"][n
|
||||
</td>
|
||||
<td>
|
||||
<TrafficBar used={s.outgoingTraffic} included={s.includedTraffic} />
|
||||
<ForecastText forecast={s.forecast} included={s.includedTraffic} />
|
||||
</td>
|
||||
<td className="text-secondary">{s.backupWindow ? `on (${s.backupWindow})` : "off"}</td>
|
||||
<td className="text-secondary">{s.monthlyPrice === null ? "—" : s.monthlyPrice.toFixed(2)}</td>
|
||||
@@ -150,8 +167,8 @@ function Card({ p }: { p: HetznerProject }) {
|
||||
</div>
|
||||
{cost && (
|
||||
<div className="text-secondary small mb-3">
|
||||
Servers {money(cost.servers, cost.currency)} · backups {money(cost.backups, cost.currency)} · volumes {money(cost.volumes, cost.currency)} · snapshots {money(cost.snapshots, cost.currency)} · primary IPs {money(cost.ips, cost.currency)}
|
||||
{cost.unassignedIps > 0 ? ` (${cost.unassignedIps} not attached to a server)` : ""}. An estimate from Hetzner’s price list: it leaves out load balancers, floating IPs and traffic over the quota{cost.unpriced > 0 ? `, and ${cost.unpriced} server(s) whose price was not given` : ""}.
|
||||
Servers {money(cost.servers, cost.currency)} · backups {money(cost.backups, cost.currency)} · volumes {money(cost.volumes, cost.currency)} · snapshots {money(cost.snapshots, cost.currency)} · primary IPs {money(cost.ips, cost.currency)} · load balancers {money(cost.loadBalancers ?? 0, cost.currency)} · floating IPs {money(cost.floatingIps ?? 0, cost.currency)}
|
||||
{cost.unassignedIps > 0 ? ` (${cost.unassignedIps} not attached to a server)` : ""}. An estimate from Hetzner’s price list: it leaves out traffic over the quota{cost.unpriced > 0 ? `, and ${cost.unpriced} server(s) whose price was not given` : ""}.
|
||||
</div>
|
||||
)}
|
||||
<div className="table-responsive">
|
||||
@@ -182,6 +199,96 @@ function Card({ p }: { p: HetznerProject }) {
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{s.loadBalancers && s.loadBalancers.length > 0 && (
|
||||
<>
|
||||
<h4 className="mt-3">Load balancers</h4>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Address</th>
|
||||
<th>Targets</th>
|
||||
<th>Traffic this month</th>
|
||||
<th>Price/mo</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{s.loadBalancers.map((l) => {
|
||||
const bad = l.targets.filter((t) => t.health === "unhealthy");
|
||||
return (
|
||||
<tr key={l.id}>
|
||||
<td className="text-break">
|
||||
<strong>{l.name}</strong>
|
||||
<div className="text-secondary small">
|
||||
{l.services} service{l.services === 1 ? "" : "s"}
|
||||
{l.algorithm ? ` · ${l.algorithm.replace("_", " ")}` : ""}
|
||||
</div>
|
||||
</td>
|
||||
<td className="text-secondary">{[l.type, l.location].filter(Boolean).join(" · ") || "—"}</td>
|
||||
<td className="text-secondary text-break">{l.ipv4 ?? "—"}</td>
|
||||
<td>
|
||||
{l.targets.length === 0 ? (
|
||||
<span className="text-secondary">none</span>
|
||||
) : bad.length === 0 ? (
|
||||
<span className="badge bg-green-lt text-green">{l.targets.every((t) => t.health === "healthy") ? `${l.targets.length} healthy` : `${l.targets.length} · not judged yet`}</span>
|
||||
) : (
|
||||
<span className="badge bg-red-lt text-red">{bad.length} of {l.targets.length} unhealthy</span>
|
||||
)}
|
||||
<div className="text-secondary small text-break">{l.targets.map((t) => `${t.serverName ?? t.label ?? "target"}${t.health === "unhealthy" ? " ✗" : ""}`).join(", ")}</div>
|
||||
</td>
|
||||
<td>
|
||||
<TrafficBar used={l.outgoingTraffic} included={l.includedTraffic} />
|
||||
</td>
|
||||
<td className="text-secondary">{l.monthlyPrice === null ? "—" : l.monthlyPrice.toFixed(2)}</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{s.floatingIps && s.floatingIps.length > 0 && (
|
||||
<>
|
||||
<h4 className="mt-3">Floating IPs</h4>
|
||||
<ul className="mb-0">
|
||||
{s.floatingIps.map((f) => (
|
||||
<li key={f.id}>
|
||||
<code>{f.ip}</code>
|
||||
{f.name ? ` (${f.name})` : ""} — {f.serverId === null ? <span className="text-yellow">points at no server (still billed)</span> : f.serverName ? `points at ${f.serverName}` : `points at a server (#${f.serverId})`}
|
||||
{f.location ? `, ${f.location}` : ""}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
{s.certificates && s.certificates.length > 0 && (
|
||||
<>
|
||||
<h4 className="mt-3">Certificates</h4>
|
||||
<ul className="mb-0">
|
||||
{s.certificates.map((c) => {
|
||||
const left = c.notValidAfter === null ? null : (Date.parse(c.notValidAfter) - Date.now()) / 86_400_000;
|
||||
return (
|
||||
<li key={c.id}>
|
||||
<strong>{c.name}</strong> ({c.type}
|
||||
{c.domains.length > 0 ? `, ${c.domains.slice(0, 3).join(", ")}${c.domains.length > 3 ? ", …" : ""}` : ""}) —{" "}
|
||||
{c.notValidAfter === null ? (
|
||||
<span className="text-secondary">{c.issuance === "failed" ? "could not be issued" : "being issued"}</span>
|
||||
) : left !== null && left <= 0 ? (
|
||||
<span className="text-red">ended <TimeAgo value={c.notValidAfter} /></span>
|
||||
) : (
|
||||
<span className={left !== null && left <= 3 ? "text-red" : left !== null && left <= 14 ? "text-yellow" : ""}>ends in {Math.ceil(left ?? 0)} days</span>
|
||||
)}
|
||||
{c.usedBy === 0 && <span className="text-secondary small"> · used by nothing</span>}
|
||||
{(c.issuance === "failed" || c.renewal === "failed") && <span className="text-red"> · {c.issuance === "failed" ? "issuing" : "renewing"} failed{c.error ? `: ${c.error}` : ""}</span>}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
{s.volumes && s.volumes.length > 0 && (
|
||||
<>
|
||||
<h4 className="mt-3">Volumes</h4>
|
||||
@@ -241,7 +348,7 @@ export default function Hetzner() {
|
||||
<h2 className="page-title">Hetzner Cloud</h2>
|
||||
<p className="text-secondary">
|
||||
One project per integration, read every few minutes (see <Link to="/integrations">Integrations</Link>) — nothing is started, stopped or changed. <strong>A server that was running and is now off</strong>, <strong>traffic close to the month’s quota</strong>,{" "}
|
||||
<strong>rescue mode left on</strong> and <strong>backups that are late</strong> are alerts — see <Link to="/alerts">Alerts</Link>.
|
||||
<strong>rescue mode left on</strong>, <strong>backups that are late</strong>, <strong>a traffic quota the month is on course to pass</strong>, <strong>unhealthy load balancer targets</strong>, <strong>certificates about to end</strong> and <strong>floating IPs that point at nothing</strong> are alerts — see <Link to="/alerts">Alerts</Link>.
|
||||
</p>
|
||||
<ErrorNotice error={error} />
|
||||
{!data && !error && <BlockSkeleton lines={4} />}
|
||||
|
||||
@@ -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’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} />)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -27,6 +27,9 @@ export const TYPE_LABELS: Record<IntegrationType, string> = {
|
||||
hetzner: "Hetzner Cloud",
|
||||
speedtest: "Speedtest Tracker",
|
||||
fragnet: "Fragnet game servers",
|
||||
sonarr: "Sonarr",
|
||||
radarr: "Radarr",
|
||||
prowlarr: "Prowlarr",
|
||||
};
|
||||
|
||||
/** The page each kind of integration gets once it is connected. */
|
||||
@@ -56,12 +59,15 @@ export const TYPE_PAGES: Record<IntegrationType, string> = {
|
||||
hetzner: "/hetzner",
|
||||
speedtest: "/speedtest",
|
||||
fragnet: "/game-servers",
|
||||
sonarr: "/media",
|
||||
radarr: "/media",
|
||||
prowlarr: "/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", "immich", "paperless", "nextcloud", "authentik"] },
|
||||
{ id: "apps", label: "Apps", types: ["homeassistant", "jellyfin", "sonarr", "radarr", "prowlarr", "immich", "paperless", "nextcloud", "authentik"] },
|
||||
{ id: "backups", label: "Backups", types: ["pbs"] },
|
||||
{ id: "network", label: "Network", types: ["unifi", "npm", "phpipam", "netbox"] },
|
||||
{ id: "monitoring", label: "Monitoring", types: ["uptimekuma", "prometheus", "ups", "speedtest"] },
|
||||
|
||||
Reference in new issue
Block a user