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

+46
View File
@@ -0,0 +1,46 @@
import { Router } from "express";
import { inArray } from "drizzle-orm";
import { db } from "../db/client.js";
import { arrState, integrations } from "../db/schema.js";
import { requireAuth } from "../auth/middleware.js";
import { ARR_KINDS, type ArrKind } from "../integrations/arr/adapter.js";
import { arrProblems, arrSyncStatuses, distinctDisks, isArrFresh, stuckItems, storedOf } from "../services/arrSync.js";
import { asyncHandler } from "../utils/asyncHandler.js";
export const arrRouter = Router();
arrRouter.use(requireAuth);
/** Every Sonarr, Radarr and Prowlarr, how it is, from what the last reads stored: what it says is wrong, its queue (with what is stuck), disks, missing items and indexers. Everyone signed in can see it. Nothing here changes anything in them. */
arrRouter.get("/", asyncHandler(async (_req, res) => {
const [rows, states, statuses] = await Promise.all([
db.select({ id: integrations.id, type: integrations.type, name: integrations.name, enabled: integrations.enabled, baseUrl: integrations.baseUrl }).from(integrations).where(inArray(integrations.type, ARR_KINDS)).orderBy(integrations.name),
db.select().from(arrState),
arrSyncStatuses(),
]);
const byId = new Map(states.map((s) => [s.integrationId, s]));
const now = Date.now();
res.json({
apps: rows.map((r) => {
const row = byId.get(r.id);
const state = row ? storedOf(row) : null;
const status = statuses[r.id] ?? null;
const fresh = isArrFresh(status ?? undefined, now);
return {
id: r.id,
kind: r.type as ArrKind,
name: r.name,
enabled: r.enabled,
url: r.baseUrl,
status,
fresh,
state: state && {
...state,
disks: state.disks && distinctDisks(state.disks),
/** The ids of the queue items that are stuck, so the page marks them the way the alert counts them. */
stuck: stuckItems(state.queue, now).map((i) => i.id),
},
problems: state && fresh ? arrProblems(r.type as ArrKind, r.id, r.name, state, now) : [],
};
}),
});
}));