diff --git a/INTEGRATIONS.md b/INTEGRATIONS.md index 0b731c1..a247f12 100644 --- a/INTEGRATIONS.md +++ b/INTEGRATIONS.md @@ -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`. diff --git a/README.md b/README.md index f1f1566..c466799 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/web/src/pages/Dashboard.tsx b/web/src/pages/Dashboard.tsx index 49a119e..b16598f 100644 --- a/web/src/pages/Dashboard.tsx +++ b/web/src/pages/Dashboard.tsx @@ -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 Disabled; + if (!t || !t.state) return Not read yet; + if (!t.fresh) return Can’t be read; + if (t.problems.some((p) => p.severity === "critical")) return Needs a look; + if (t.problems.length > 0) return Needs a look; + return In order; +} + +const TECHNITIUM_HOW_COLORS: Record = { "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
Switched off under Integrations.
; + if (loading) return ; + const s = instance?.state ?? null; + const open = ( +
+ Open Technitium DNS +
+ ); + if (!instance || !s) { + return ( + <> +
Not read yet.
+ {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 ( + <> +
+
+ +
+
+ +
+
+ 0 ? "#f59e0b" : undefined} /> +
+
+ {how.length > 0 && } + {!s.blockingEnabled && s.settings.blockLists.count > 0 &&
Blocking is switched off.
} + {!instance.fresh &&
The last read is old, so this may be out of date.
} + {instance.problems.slice(0, 2).map((p) => ( +
+ {p.message} +
+ ))} + {instance.problems.length > 2 &&
and {instance.problems.length - 2} more
} + {open} + + ); +} + /** What each group of integrations is, in a line — the groups are the sidebar's. */ const GROUP_HINTS: Record = { infrastructure: "The systems your servers and containers run on.", @@ -367,6 +435,8 @@ export default function Dashboard({ user }: { user: CurrentUser }) { const [integrations, setIntegrations] = useState(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>(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(null); const [tailscaleSummary, setTailscaleSummary] = useState(null); const [tailscaleExtra, setTailscaleExtra] = useState(null); const [giteaSummary, setGiteaSummary] = useState(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 }) { ); })} + {/* 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 ( + + + + ); + })} ))}