Hetzner Cloud integration: servers, traffic quota, backups, volumes and cost

One integration per project (read-only API token, read every 5 minutes).
Alerts for a server that was running and is off, stuck statuses, traffic
at 80%/100% of the monthly quota, rescue mode left on, and late backups.
The Hetzner page lists servers, volumes, snapshots and a cost estimate; a
server the app knows by its agent gets a Hetzner card on its own page.
/metrics and docs updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-25 22:51:17 +01:00
1 parent 5a2b320175
commit 24b708abbe
35 files changed
+9430 -7

No files matched your search

+2
View File
@@ -19,6 +19,7 @@ import Paperless from "./pages/Paperless";
import N8n from "./pages/N8n";
import NetBox from "./pages/NetBox";
import Nextcloud from "./pages/Nextcloud";
import Hetzner from "./pages/Hetzner";
import ServiceLevels from "./pages/ServiceLevels";
import Duplicati from "./pages/Duplicati";
import MyWorkPage from "./pages/MyWork";
@@ -174,6 +175,7 @@ function Shelled({ user }: { user: CurrentUser }) {
<Route path="/n8n" element={<N8n />} />
<Route path="/netbox" element={<NetBox />} />
<Route path="/nextcloud" element={<Nextcloud />} />
<Route path="/hetzner" element={<Hetzner />} />
<Route path="/service-levels" element={<ServiceLevels user={user} />} />
<Route path="/duplicati" element={<Duplicati user={user} />} />
<Route path="/ports" element={<Ports user={user} />} />
+73 -1
View File
@@ -1258,6 +1258,74 @@ export interface NextcloudInfo {
problems: { key: string; message: string; severity: "warning" | "critical" }[];
}
export interface HetznerServerInfo {
id: number;
name: string;
status: string;
created: string | null;
type: string | null;
cores: number | null;
memoryGb: number | null;
diskGb: number | null;
location: string | null;
city: string | null;
os: string | null;
ipv4: string | null;
ipv6: string | null;
privateIps: string[];
locked: boolean;
rescueEnabled: boolean;
/** The hour backups are taken in; null when they are not enabled. */
backupWindow: string | null;
/** This month's traffic, in bytes. */
includedTraffic: number | null;
outgoingTraffic: number | null;
ingoingTraffic: number | null;
monthlyPrice: number | null;
lastRunningAt: string | null;
statusSince: string;
rescueSince: string | null;
}
export interface HetznerProblemInfo {
key: string;
serverId: number;
message: string;
severity: "warning" | "critical";
}
/** One Hetzner Cloud project (an integration of type hetzner), as its page shows it. */
export interface HetznerProject {
id: number;
name: string;
enabled: boolean;
status: { at: string; ok: boolean; error: string | null } | null;
fresh: boolean;
state: {
/** linked: the server the app knows by its agent that this is; null when there is none. */
servers: (HetznerServerInfo & { linked: { id: number; name: string } | null })[];
/** 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;
updatedAt: string;
} | null;
problems: HetznerProblemInfo[];
}
export interface HetznerForServer {
match: {
integrationId: number;
integrationName: string;
fresh: boolean;
updatedAt: string;
server: HetznerServerInfo;
newestBackup: string | null;
snapshots: number;
problems: HetznerProblemInfo[];
} | null;
}
/** One NetBox, as its page shows it. */
export interface NetBoxInfo {
id: number;
@@ -2315,7 +2383,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";
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";
export interface IntegrationField {
key: string;
@@ -2900,6 +2968,10 @@ export const api = {
netbox: {
list: () => request<{ netboxes: NetBoxInfo[] }>("/api/netbox"),
},
hetzner: {
list: () => request<{ projects: HetznerProject[] }>("/api/hetzner"),
forServer: (serverId: number) => request<HetznerForServer>(`/api/hetzner/for-server/${serverId}`),
},
n8n: {
list: () => request<{ n8ns: N8nInfo[] }>("/api/n8n"),
},
+1
View File
@@ -55,6 +55,7 @@ const INTEGRATION_TYPE_LABELS: Record<IntegrationType, string> = {
n8n: "n8n",
netbox: "NetBox",
nextcloud: "Nextcloud",
hetzner: "Hetzner Cloud",
};
const DNS_PROVIDER_LABELS: Record<DnsProviderType, string> = {
+68
View File
@@ -0,0 +1,68 @@
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";
/** 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 }) {
const [match, setMatch] = useState<HetznerForServer["match"]>(null);
useEffect(() => {
let live = true;
api.hetzner
.forServer(serverId)
.then((r) => live && setMatch(r.match))
.catch(() => live && setMatch(null));
return () => {
live = false;
};
}, [serverId]);
if (!match) return null;
const s = match.server;
return (
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">Hetzner Cloud</h3>
<div className="card-actions">
<Link to="/hetzner" className="btn btn-sm btn-outline-secondary">
{match.integrationName}
</Link>
</div>
</div>
<div className="card-body">
{match.problems.length > 0 && (
<ul className="mb-3">
{match.problems.map((p) => (
<li key={p.key} className={p.severity === "critical" ? "text-red" : ""}>
{p.message}
</li>
))}
</ul>
)}
<div className="row g-3">
<div className="col-6 col-lg-3">
<div className="text-secondary small">Status</div>
<StatusBadge status={s.status} />
{s.rescueEnabled && <span className="badge bg-yellow-lt text-yellow ms-1">rescue on</span>}
</div>
<div className="col-6 col-lg-3">
<div className="text-secondary small">Type and place</div>
{s.type ?? "—"} · {s.location ?? "?"}
</div>
<div className="col-6 col-lg-3">
<div className="text-secondary small">Backups</div>
{s.backupWindow ? (match.newestBackup ? <>newest <TimeAgo value={match.newestBackup} /></> : "on, none made yet") : "off"}
{match.snapshots > 0 && <span className="text-secondary small"> · {match.snapshots} snapshot{match.snapshots === 1 ? "" : "s"}</span>}
</div>
<div className="col-6 col-lg-3">
<div className="text-secondary small">Traffic this month</div>
<TrafficBar used={s.outgoingTraffic} included={s.includedTraffic} />
</div>
</div>
<div className="text-secondary small mt-2">
{match.fresh ? <>read <TimeAgo value={match.updatedAt} /></> : "Hetzner could not be read lately — this is how it was"}
</div>
</div>
</div>
);
}
@@ -26,6 +26,7 @@ const TYPE_LABELS: Record<IntegrationType, string> = {
n8n: "n8n",
netbox: "NetBox",
nextcloud: "Nextcloud",
hetzner: "Hetzner Cloud",
};
export default function IntegrationEditForm({
+1
View File
@@ -25,6 +25,7 @@ const TYPE_LABELS: Record<IntegrationType, string> = {
n8n: "n8n",
netbox: "NetBox",
nextcloud: "Nextcloud",
hetzner: "Hetzner Cloud",
};
export default function IntegrationForm({ onCreated, onCancel }: { onCreated: () => void; onCancel: () => void }) {
+1
View File
@@ -27,6 +27,7 @@ const TYPE_LABELS: Record<string, string> = {
n8n: "n8n",
netbox: "NetBox",
nextcloud: "Nextcloud",
hetzner: "Hetzner Cloud",
};
export type WallLevel = "critical" | "warning" | "ok" | "unsure";
+2
View File
@@ -19,6 +19,7 @@ import {
IconAffiliate,
IconCloud,
IconBinaryTree,
IconServerBolt,
IconBolt,
IconFileText,
IconFlame,
@@ -137,6 +138,7 @@ export const NAV: NavEntry[] = [
{ to: "/n8n", label: "n8n", icon: <IconBolt size={20} /> },
{ to: "/netbox", label: "NetBox", icon: <IconBinaryTree size={20} /> },
{ to: "/nextcloud", label: "Nextcloud", icon: <IconCloud size={20} /> },
{ to: "/hetzner", label: "Hetzner Cloud", icon: <IconServerBolt size={20} /> },
{ to: "/service-levels", label: "Service levels", icon: <IconTargetArrow size={20} /> },
],
},
+258
View File
@@ -0,0 +1,258 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type HetznerProject } 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";
function Badge({ p }: { p: HetznerProject }) {
if (!p.enabled) return <span className="badge bg-secondary-lt text-secondary">Off</span>;
if (!p.state) return <span className="badge bg-secondary-lt text-secondary">Not read yet</span>;
if (!p.fresh) return <span className="badge bg-yellow-lt text-yellow">Can&rsquo;t be read</span>;
if (p.problems.some((x) => x.severity === "critical")) return <span className="badge bg-red-lt text-red">Needs a look</span>;
if (p.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>;
}
export function StatusBadge({ status }: { status: string }) {
if (status === "running") return <span className="badge bg-green-lt text-green">Running</span>;
if (status === "off") return <span className="badge bg-secondary-lt text-secondary">Off</span>;
return <span className="badge bg-yellow-lt text-yellow">{status}</span>;
}
/** 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>;
const share = used / included;
return (
<div style={{ minWidth: 150 }}>
<div className="progress progress-sm">
<div className={`progress-bar ${share >= 1 ? "bg-red" : share >= 0.8 ? "bg-yellow" : "bg-green"}`} style={{ width: `${Math.min(100, share * 100)}%` }} />
</div>
<div className="small text-secondary">
{formatBytes(used)} of {formatBytes(included)} ({Math.floor(share * 100)}%)
</div>
</div>
);
}
const money = (n: number, currency: string) => {
try {
return new Intl.NumberFormat(undefined, { style: "currency", currency }).format(n);
} catch {
return `${n.toFixed(2)} ${currency}`;
}
};
function ServerRow({ s }: { s: NonNullable<HetznerProject["state"]>["servers"][number] }) {
return (
<tr>
<td className="text-break">
{s.linked ? <Link to={`/servers/${s.linked.id}`}>{s.name}</Link> : <strong>{s.name}</strong>}
{!s.linked && <div className="text-secondary small">no agent here — not in the app&rsquo;s servers</div>}
{s.os && <div className="text-secondary small">{s.os}</div>}
</td>
<td>
<StatusBadge status={s.status} />
{s.rescueEnabled && <span className="badge bg-yellow-lt text-yellow ms-1">rescue on</span>}
{s.locked && <span className="badge bg-secondary-lt text-secondary ms-1">locked</span>}
{s.status !== "running" && (
<div className="text-secondary small">
since <TimeAgo value={s.statusSince} />
</div>
)}
</td>
<td className="text-secondary">
{s.type ?? "—"}
<div className="small">{[s.cores !== null ? `${s.cores} cores` : null, s.memoryGb !== null ? `${s.memoryGb} GB RAM` : null, s.diskGb !== null ? `${s.diskGb} GB disk` : null].filter(Boolean).join(" · ")}</div>
</td>
<td className="text-secondary">{[s.city, s.location].filter(Boolean).join(" · ") || "—"}</td>
<td className="text-secondary text-break">
{s.ipv4 ?? "—"}
{s.privateIps.length > 0 && <div className="small">{s.privateIps.join(", ")}</div>}
</td>
<td>
<TrafficBar used={s.outgoingTraffic} 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>
</tr>
);
}
function Card({ p }: { p: HetznerProject }) {
const s = p.state;
const cost = s?.cost ?? null;
const gb = (s?.volumes ?? []).reduce((sum, v) => sum + v.size, 0);
const snapshots = (s?.images ?? []).filter((i) => i.type === "snapshot").sort((a, b) => (b.created ?? "").localeCompare(a.created ?? ""));
const backups = (s?.images ?? []).filter((i) => i.type === "backup");
return (
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">
{p.name} <Badge p={p} />
</h3>
<div className="card-actions text-secondary small">{p.status ? <>read <TimeAgo value={p.status.at} /></> : "not read yet"}</div>
</div>
<div className="card-body">
{p.status && !p.status.ok && <div className="text-yellow mb-2">The last attempt to read it failed: {p.status.error ?? "no answer"}.</div>}
{p.problems.length > 0 && (
<ul className="mb-3">
{p.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">
<div className="col-6 col-lg-3">
<div className="card card-sm h-100">
<div className="card-body">
<div className="text-secondary small">Servers</div>
<div className="h2 mb-0">{s.servers.length}</div>
<div className="text-secondary small">{s.servers.filter((x) => x.status === "running").length} running</div>
</div>
</div>
</div>
<div className="col-6 col-lg-3">
<div className="card card-sm h-100">
<div className="card-body">
<div className="text-secondary small">Estimated per month</div>
<div className="h2 mb-0">{cost ? money(cost.total, cost.currency) : "—"}</div>
<div className="text-secondary small">{cost ? "at list prices, with VAT" : "the price list could not be read"}</div>
</div>
</div>
</div>
<div className="col-6 col-lg-3">
<div className="card card-sm h-100">
<div className="card-body">
<div className="text-secondary small">Volumes</div>
<div className="h2 mb-0">{s.volumes === null ? "—" : s.volumes.length}</div>
<div className="text-secondary small">{s.volumes === null ? "could not be read" : `${gb} GB${s.volumes.some((v) => v.serverId === null) ? `, ${s.volumes.filter((v) => v.serverId === null).length} not attached` : ""}`}</div>
</div>
</div>
</div>
<div className="col-6 col-lg-3">
<div className="card card-sm h-100">
<div className="card-body">
<div className="text-secondary small">Snapshots and backups</div>
<div className="h2 mb-0">{s.images === null ? "—" : `${snapshots.length} + ${backups.length}`}</div>
<div className="text-secondary small">{s.images === null ? "could not be read" : "snapshots + backups"}</div>
</div>
</div>
</div>
</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&rsquo;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` : ""}.
</div>
)}
<div className="table-responsive">
<table className="table table-vcenter card-table">
<thead>
<tr>
<th>Server</th>
<th>Status</th>
<th>Type</th>
<th>Location</th>
<th>Address</th>
<th>Traffic this month</th>
<th>Backups</th>
<th>Price/mo</th>
</tr>
</thead>
<tbody>
{s.servers.map((x) => (
<ServerRow key={x.id} s={x} />
))}
{s.servers.length === 0 && (
<tr>
<td colSpan={8} className="text-secondary">
The project has no servers.
</td>
</tr>
)}
</tbody>
</table>
</div>
{s.volumes && s.volumes.length > 0 && (
<>
<h4 className="mt-3">Volumes</h4>
<ul className="mb-0">
{s.volumes.map((v) => (
<li key={v.id}>
<strong>{v.name}</strong> — {v.size} GB, {v.location ?? "?"}, {v.serverName ? `on ${v.serverName}` : v.serverId === null ? <span className="text-yellow">not attached to a server (still billed)</span> : `on a server (#${v.serverId})`}
</li>
))}
</ul>
</>
)}
{snapshots.length > 0 && (
<>
<h4 className="mt-3">Snapshots</h4>
<ul className="mb-0">
{snapshots.map((i) => (
<li key={i.id}>
<strong>{i.description ?? `#${i.id}`}</strong> — {i.sizeGb === null ? "being made" : `${i.sizeGb.toFixed(1)} GB`}, {i.serverName ? `of ${i.serverName}` : "of a server that is gone"}
{i.created && (
<>
, taken <TimeAgo value={i.created} />
</>
)}
</li>
))}
</ul>
<div className="text-secondary small mt-1">Snapshots are billed per GB and month until they are deleted.</div>
</>
)}
</>
)}
</div>
</div>
);
}
/** Hetzner Cloud: each project's servers, what is close to its traffic quota, which have backups, and roughly what it all costs. */
export default function Hetzner() {
const [data, setData] = useState<HetznerProject[] | null>(null);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const load = () =>
api.hetzner
.list()
.then((r) => {
setData(r.projects);
setError(null);
})
.catch((err) => setError(readableError(err)));
void load();
const t = setInterval(load, 60_000);
return () => clearInterval(t);
}, []);
return (
<>
<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&rsquo;s quota</strong>,{" "}
<strong>rescue mode left on</strong> and <strong>backups that are late</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 Hetzner project connected" hint="Add one under Integrations with a project's API token (Hetzner Console → the project → Security → API tokens; Read is enough)." />
</div>
</div>
)}
{data?.map((p) => <Card key={p.id} p={p} />)}
</>
);
}
+2
View File
@@ -37,6 +37,7 @@ const TYPE_LABELS: Record<IntegrationType, string> = {
n8n: "n8n",
netbox: "NetBox",
nextcloud: "Nextcloud",
hetzner: "Hetzner Cloud",
};
/** The page each kind of integration gets once it is connected. */
@@ -63,6 +64,7 @@ const TYPE_PAGES: Record<IntegrationType, string> = {
n8n: "/n8n",
netbox: "/netbox",
nextcloud: "/nextcloud",
hetzner: "/hetzner",
};
/** "pve.example.lan" out of "https://pve.example.lan:8006/", or the text itself when it isn't an address. */
+3
View File
@@ -41,6 +41,7 @@ import { useBreadcrumbTail } from "../utils/breadcrumb";
import { PageSkeleton } from "../components/Skeleton";
import ViewTabs from "../components/ViewTabs";
import ConnectedThrough from "../components/ConnectedThrough";
import HetznerServerCard from "../components/HetznerServerCard";
const SCHEDULE_TYPE_OPTIONS: { value: ScheduleType; label: string }[] = Object.entries(SCHEDULE_TYPE_LABELS).map(
([value, label]) => ({ value: value as ScheduleType, label }),
@@ -537,6 +538,8 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
</div>
</div>
<HetznerServerCard serverId={serverId} />
<div className="row row-cards mb-3">
<div className="col-lg-7">
<div className="card h-100">
+1
View File
@@ -35,6 +35,7 @@ const INTEGRATION_NAMES: Record<string, string> = {
n8n: "n8n",
netbox: "NetBox",
nextcloud: "Nextcloud",
hetzner: "Hetzner Cloud",
};
function ColorList({