Show cluster health in the Technitium DNS integration

Reads /api/admin/cluster/state (Technitium 14+): a Cluster table on the page,
alerts for a node unreachable for ten minutes (primary critical) and for a
secondary that has stopped taking the primary's configuration, and three
/metrics series. A server in no cluster shows nothing; a token that may not
view administration is told so and the rest of the read is unaffected.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-08 23:37:11 +01:00
1 parent 1ef686d1ba
commit d78aba8bf9
15 files changed
+9423 -15

No files matched your search

+68 -1
View File
@@ -63,6 +63,71 @@ function upFor(startedAt: string, now: number = Date.now()): string {
return hours % 24 ? `${days} d ${hours % 24} h` : `${days} d`;
}
const NODE_STATE: Record<string, { className: string; label: string }> = {
self: { className: "bg-blue-lt", label: "this node" },
connected: { className: "bg-green-lt", label: "connected" },
unreachable: { className: "bg-red-lt", label: "unreachable" },
};
/** The cluster the server belongs to: its nodes and whether this one can reach them, and (for a secondary) when it last took the configuration from the primary. Nothing when it is in none. */
function ClusterSection({ cluster }: { cluster: NonNullable<TechnitiumInstance["state"]>["cluster"] }) {
if (!cluster || (!cluster.info && !cluster.note)) return null;
const info = cluster.info;
return (
<div className="mb-3">
<h4>Cluster{info?.domain ? <span className="text-secondary fw-normal"> — {info.domain}</span> : null}</h4>
{cluster.note && <div className={`small mb-2 ${info ? "text-yellow" : "text-secondary"}`}>{cluster.note}</div>}
{info && (
<>
<div className="table-responsive">
<table className="table table-sm table-vcenter mb-2">
<thead>
<tr>
<th>Node</th>
<th>Role</th>
<th>State</th>
<th>Version</th>
<th>Last seen</th>
</tr>
</thead>
<tbody>
{info.nodes.map((n) => {
const st = NODE_STATE[n.state.toLowerCase()] ?? { className: "bg-secondary-lt", label: n.state };
return (
<tr key={n.id ?? n.name}>
<td className="text-nowrap">
{n.url ? (
<a href={n.url} target="_blank" rel="noreferrer">
{n.name}
</a>
) : (
n.name
)}
</td>
<td>{n.type}</td>
<td>
<span className={`badge ${st.className}`}>{st.label}</span>
</td>
<td className="text-secondary">{n.version ?? "—"}</td>
<td className="text-secondary">{n.state.toLowerCase() === "self" ? "—" : n.lastSeen ? <TimeAgo value={n.lastSeen} /> : "—"}</td>
</tr>
);
})}
</tbody>
</table>
</div>
{info.configLastSynced && (
<div className="small text-secondary">
This node last took the configuration from the primary <TimeAgo value={info.configLastSynced} />
{info.configRefreshSeconds ? ` (it asks every ${Math.round(info.configRefreshSeconds / 60)} min)` : ""}.
</div>
)}
</>
)}
</div>
);
}
/** How the last day's queries were answered, as one bar: from the cache, resolved by the server, from its own zones, blocked, dropped. */
const HOW: { key: "cached" | "recursive" | "authoritative" | "blocked" | "dropped"; label: string; className: string }[] = [
{ key: "cached", label: "from the cache", className: "bg-blue" },
@@ -159,6 +224,8 @@ function Card({ a, canRead, onRead }: { a: TechnitiumInstance; canRead: boolean;
</div>
)}
<ClusterSection cluster={s.cluster} />
<h4>Zones</h4>
{s.zones === null ? (
<div className="text-secondary small mb-3">They could not be read.</div>
@@ -250,7 +317,7 @@ export default function TechnitiumDns({ user }: { user: CurrentUser }) {
<h2 className="page-title">Technitium DNS</h2>
<p className="text-secondary">
Read every two minutes (see <Link to="/integrations">Integrations</Link>), with a real DNS question put to it each time — its web console can be up while DNS is not. Nothing is changed. <strong>DNS that stops answering</strong>, <strong>blocking left off for an hour</strong>,{" "}
<strong>block lists that stopped updating</strong> and <strong>an expired or unsynced zone</strong> are alerts — see <Link to="/alerts">Alerts</Link>. Technitium does not report the CPU, memory or disk of the machine it runs on: put a <Link to="/servers">server agent</Link> there for that.
<strong>block lists that stopped updating</strong> and <strong>an expired or unsynced zone</strong>, <strong>a cluster node that cannot be reached</strong> and <strong>a secondary that has stopped taking the primary's configuration</strong> are alerts — see <Link to="/alerts">Alerts</Link>. Technitium does not report the CPU, memory or disk of the machine it runs on: put a <Link to="/servers">server agent</Link> there for that.
</p>
<ErrorNotice error={error} />
{!data && !error && <BlockSkeleton lines={4} />}