Add a Technitium DNS widget to the dashboard
A card in the Network section replaces the generic tile: whether DNS answers and how fast, the last day's queries and the share blocked, a bar of how they were answered, blocking left off, a stale reading, and what is wrong (the first two alerts). It follows the other cards: a status badge that colours the edge and puts it first when it has a problem, hide and move under Customise, refreshed every minute from the same data as the Technitium page. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a2ff0f7daa
commit
f73704e6ca
3 files changed
+99
-2
No files matched your search
+1
-1
@@ -450,7 +450,7 @@ osTicket's API cannot close a ticket, so this is the one place in the app that *
|
||||
|
||||
- **Config fields:** the **URL** of its web console (`http://dns.example.lan:5380`) and an **API token** — a non-expiring one, made under Administration → Sessions → *Create Token*; stored encrypted — of a user who may **view** the dashboard, the settings and the zones (and the DHCP server, for the DHCP counts). Optional: the **DNS server address** (the host of the URL unless told — fill it in if a reverse proxy sits in front of the console), the **name to test DNS with** (`example.com`) and *Allow self-signed certificate*. Zones and records are connected separately, as a **DNS provider** on the DNS page, with a token of its own; this integration only says how the server is doing.
|
||||
- **Required access:** the console reachable from the app over HTTP(S) and — for the DNS test — the DNS port (the first of the server's listening endpoints, usually 53) reachable from the app **over UDP**. The token goes in an `Authorization: Bearer` header, which Technitium **15.0 and later** require; an older server answers "token not accepted". If the app sits where UDP 53 to it is blocked, the test says so (no answer) and DNS is reported down; allow it or set the DNS server address to one the app can reach.
|
||||
- **What it does:** every **two minutes** it reads `GET /api/settings/get` (version, when it started, whether blocking is on, the block lists and when they are next updated, the cache limit, recursion, DNSSEC, the DNS port), `GET /api/dashboard/stats/get?type=LastDay` (the last day's queries and how each ended, clients, cache entries, zone and list counts, the clients and names asked about and blocked most), `GET /api/zones/list` (which secondary zones have expired or cannot sync; the server's own internal zones and switched-off zones are not judged) and `GET /api/dhcp/scopes/list` and `…/leases/list` (scopes and lease counts) — and puts **one DNS question** to its DNS server, as for AdGuard Home. **Network → Technitium DNS** shows it all. Nothing is changed: blocking is never switched, no block list refreshed, no zone touched.
|
||||
- **What it does:** every **two minutes** it reads `GET /api/settings/get` (version, when it started, whether blocking is on, the block lists and when they are next updated, the cache limit, recursion, DNSSEC, the DNS port), `GET /api/dashboard/stats/get?type=LastDay` (the last day's queries and how each ended, clients, cache entries, zone and list counts, the clients and names asked about and blocked most), `GET /api/zones/list` (which secondary zones have expired or cannot sync; the server's own internal zones and switched-off zones are not judged) and `GET /api/dhcp/scopes/list` and `…/leases/list` (scopes and lease counts) — and puts **one DNS question** to its DNS server, as for AdGuard Home. **Network → Technitium DNS** shows it all, and the dashboard has a **widget** for it in its Network section (whether DNS answers and how fast, the last day's queries and the share blocked, how they were answered, and what is wrong). Nothing is changed: blocking is never switched, no block list refreshed, no zone touched.
|
||||
- **Alerts** (source *Technitium DNS*; held back by maintenance on the integration): the test question **unanswered in every read for ten minutes** (critical — one lost packet is not an outage); a **secondary zone that has expired** (critical — it no longer answers), or zones that **cannot sync** (warning), one alert for all the zones; **blocking switched off for an hour** while block lists are set up (warning — with none, off is how it is); **block lists whose update was due more than six hours ago** (warning). See [MONITORING.md](docs/MONITORING.md#technitium-dns).
|
||||
- If it cannot be read for ten minutes its alerts are neither raised nor cleared, the Alerts page says it could not check, and the integration is raised as failing like any other. A part that could not be read (the statistics, the zones, DHCP) is shown as *could not be read*, never as none; the settings are the one part that must work, since they say it is there and the token is accepted.
|
||||
- `/metrics` has `homelab_technitium_dns_up`, `homelab_technitium_dns_probe_seconds`, `homelab_technitium_blocking_enabled`, `homelab_technitium_uptime_seconds`, `homelab_technitium_block_lists_overdue`, `homelab_technitium_queries`, `homelab_technitium_blocked`, `homelab_technitium_cached`, `homelab_technitium_recursive`, `homelab_technitium_server_failures`, `homelab_technitium_clients`, `homelab_technitium_cache_entries`, `homelab_technitium_zones`, `homelab_technitium_zone_problems` and `homelab_technitium_dhcp_leases`.
|
||||
|
||||
@@ -49,6 +49,8 @@ All modules from the original plan are built:
|
||||
stored snapshots have failed verification or were never verified.
|
||||
The osTicket widget shows how many tickets are open, overdue, and awaiting
|
||||
a staff reply.
|
||||
The Technitium DNS widget (in the Network section) shows whether DNS answers and how fast, the last day's queries and the share blocked, a bar of how they were answered
|
||||
(cache, resolved, its own zones, blocked, dropped) and what is wrong with it; it is refreshed every minute and can be hidden under Customise like the rest.
|
||||
- **Diagnostic Log** (admin-only; Administration → Integrations → *Call log*) — every call this app makes to a DNS
|
||||
provider or integration (Tailscale, Proxmox, Synology, Semaphore, Gitea,
|
||||
Dockhand, Uptime Kuma, Proxmox Backup Server, osTicket), success or failure, with latency and the error message if it
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
type SecretRecord,
|
||||
type ServerSummary,
|
||||
type TailscaleDevicesResponse,
|
||||
type TechnitiumInstance,
|
||||
} from "../api/client";
|
||||
import { formatAgo } from "../utils/duration";
|
||||
import StatusStrip from "../components/StatusStrip";
|
||||
@@ -241,6 +242,73 @@ function WidgetCard({ label, badge, hide, children }: { label: string; badge?: R
|
||||
);
|
||||
}
|
||||
|
||||
/** The status badge of a Technitium DNS Server widget: switched off, not read yet, can't be read, or what its alerts say (red for a critical one, yellow for the rest). */
|
||||
function technitiumBadge(enabled: boolean, t: TechnitiumInstance | null): ReactNode {
|
||||
if (!enabled) return <span className="badge bg-secondary-lt text-secondary">Disabled</span>;
|
||||
if (!t || !t.state) return <span className="badge bg-secondary-lt text-secondary">Not read yet</span>;
|
||||
if (!t.fresh) return <span className="badge bg-yellow-lt text-yellow">Can’t be read</span>;
|
||||
if (t.problems.some((p) => p.severity === "critical")) return <span className="badge bg-red-lt text-red">Needs a look</span>;
|
||||
if (t.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>;
|
||||
}
|
||||
|
||||
const TECHNITIUM_HOW_COLORS: Record<string, string> = { "from cache": "#60a5fa", resolved: "#22d3ee", "own zones": "#4ade80", blocked: "#fb923c", dropped: "#f87171" };
|
||||
|
||||
/** What the Technitium DNS Server widget says: whether DNS answers and how fast, the last day's queries and how many were blocked, how they were answered, and what is wrong. The page has the rest. */
|
||||
function TechnitiumBody({ enabled, instance, loading }: { enabled: boolean; instance: TechnitiumInstance | null; loading: boolean }) {
|
||||
if (!enabled) return <div className="text-secondary">Switched off under Integrations.</div>;
|
||||
if (loading) return <WidgetSkeleton />;
|
||||
const s = instance?.state ?? null;
|
||||
const open = (
|
||||
<div className="mt-2">
|
||||
<Link to="/technitium">Open Technitium DNS</Link>
|
||||
</div>
|
||||
);
|
||||
if (!instance || !s) {
|
||||
return (
|
||||
<>
|
||||
<div className="text-secondary">Not read yet.</div>
|
||||
{open}
|
||||
</>
|
||||
);
|
||||
}
|
||||
const st = s.stats;
|
||||
const how = st
|
||||
? [
|
||||
{ label: "from cache", count: st.cached },
|
||||
{ label: "resolved", count: st.recursive },
|
||||
{ label: "own zones", count: st.authoritative },
|
||||
{ label: "blocked", count: st.blocked },
|
||||
{ label: "dropped", count: st.dropped },
|
||||
].filter((d) => d.count > 0)
|
||||
: [];
|
||||
return (
|
||||
<>
|
||||
<div className="row g-2 mb-3">
|
||||
<div className="col-4">
|
||||
<MiniStat label="DNS answers" value={s.probe === null ? "—" : s.probe.ok ? `${s.probe.ms ?? "?"} ms` : "No"} accent={s.probe && !s.probe.ok ? "#f87171" : undefined} />
|
||||
</div>
|
||||
<div className="col-4">
|
||||
<MiniStat label="Queries, 24 h" value={st ? st.queries.toLocaleString() : "—"} />
|
||||
</div>
|
||||
<div className="col-4">
|
||||
<MiniStat label="Blocked" value={st?.blockedPercent != null ? `${st.blockedPercent}%` : "—"} accent={!s.blockingEnabled && s.settings.blockLists.count > 0 ? "#f59e0b" : undefined} />
|
||||
</div>
|
||||
</div>
|
||||
{how.length > 0 && <BreakdownBar data={how} colors={TECHNITIUM_HOW_COLORS} compact />}
|
||||
{!s.blockingEnabled && s.settings.blockLists.count > 0 && <div className="small text-yellow mt-2">Blocking is switched off.</div>}
|
||||
{!instance.fresh && <div className="small text-yellow mt-2">The last read is old, so this may be out of date.</div>}
|
||||
{instance.problems.slice(0, 2).map((p) => (
|
||||
<div key={p.key} className={`small mt-1 ${p.severity === "critical" ? "text-red" : "text-yellow"}`}>
|
||||
{p.message}
|
||||
</div>
|
||||
))}
|
||||
{instance.problems.length > 2 && <div className="small text-secondary mt-1">and {instance.problems.length - 2} more</div>}
|
||||
{open}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/** What each group of integrations is, in a line — the groups are the sidebar's. */
|
||||
const GROUP_HINTS: Record<string, string> = {
|
||||
infrastructure: "The systems your servers and containers run on.",
|
||||
@@ -367,6 +435,8 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
const [integrations, setIntegrations] = useState<IntegrationSummary[] | null>(null);
|
||||
// How many alerts each integration has open that nobody has put aside, for the tiles of the integrations that have no widget of their own.
|
||||
const [integrationAlerts, setIntegrationAlerts] = useState<Map<number, { count: number; critical: boolean }>>(new Map());
|
||||
// What each Technitium DNS Server says (the same as its page), read once there is one and then every minute.
|
||||
const [technitium, setTechnitium] = useState<TechnitiumInstance[] | null>(null);
|
||||
const [tailscaleSummary, setTailscaleSummary] = useState<TailscaleDevicesResponse["summary"] | null>(null);
|
||||
const [tailscaleExtra, setTailscaleExtra] = useState<TailscaleExtra | null>(null);
|
||||
const [giteaSummary, setGiteaSummary] = useState<GiteaSummary | null>(null);
|
||||
@@ -457,6 +527,19 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
.catch(() => {});
|
||||
}, []);
|
||||
|
||||
const hasTechnitium = integrations?.some((i) => i.type === "technitium") ?? false;
|
||||
useEffect(() => {
|
||||
if (!hasTechnitium) return;
|
||||
const load = () =>
|
||||
api.technitium
|
||||
.list()
|
||||
.then((r) => setTechnitium(r.instances))
|
||||
.catch(() => setTechnitium((current) => current ?? []));
|
||||
void load();
|
||||
const t = setInterval(load, 60_000);
|
||||
return () => clearInterval(t);
|
||||
}, [hasTechnitium]);
|
||||
|
||||
useEffect(() => {
|
||||
const tailscale = integrations?.find((i) => i.type === "tailscale" && i.enabled);
|
||||
if (!tailscale) {
|
||||
@@ -1435,7 +1518,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
})}
|
||||
{/* The integrations with no widget of their own get a small tile: whether they work, how many alerts are open, and where to look. */}
|
||||
{(integrations ?? [])
|
||||
.filter((i) => group.types.includes(i.type) && !WIDGETS.some((w) => w.type === i.type))
|
||||
.filter((i) => group.types.includes(i.type) && !WIDGETS.some((w) => w.type === i.type) && i.type !== "technitium")
|
||||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
.map((i) => {
|
||||
const alerts = integrationAlerts.get(i.id);
|
||||
@@ -1470,6 +1553,18 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
</WidgetCard>
|
||||
);
|
||||
})}
|
||||
{/* Technitium DNS Server has a widget of its own: the DNS test, the last day's queries and how they were answered, and what is wrong. */}
|
||||
{(integrations ?? [])
|
||||
.filter((i) => group.types.includes(i.type) && i.type === "technitium")
|
||||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
.map((i) => {
|
||||
const instance = technitium?.find((x) => x.id === i.id) ?? null;
|
||||
return (
|
||||
<WidgetCard key={i.id} label={i.name === TYPE_LABELS[i.type] ? i.name : `${TYPE_LABELS[i.type]}: ${i.name}`} badge={technitiumBadge(i.enabled, instance)}>
|
||||
<TechnitiumBody enabled={i.enabled} instance={instance} loading={technitium === null} />
|
||||
</WidgetCard>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Fragment>
|
||||
))}
|
||||
|
||||
Reference in new issue
Block a user