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
+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} />}
|
||||
|
||||
Reference in new issue
Block a user