UniFi integration: network devices, Wi-Fi and networks, as part of the dependency map

A UniFi controller (API key on Network 9+, or a read-only local login on any
version) is read every five minutes. Its switches, access points and gateways
are kept with state, IP, uptime, firmware and uplink; its networks and Wi-Fi
names beside them (passphrases are never read). Nothing is written to the
controller.

Network > Network devices lists them. Devices are a new node type in the
dependency map: uplinks become dependencies by themselves, others can be
written by hand. A device offline past a limit is an offline alert, folds what
depends on it, can be silenced with maintenance and have runbooks.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-20 00:35:48 +02:00
1 parent 73a06ebe63
commit 396e074108
48 files changed
+6893 -102

No files matched your search

+17 -14
View File
@@ -8,9 +8,9 @@ import { readableError } from "../utils/errors";
import { toast } from "../utils/toast";
import { EmptyRow } from "../components/EmptyState";
const TYPE_LABELS = { server: "Server", integration: "Integration" } as const;
const TYPE_LABELS = { server: "Server", integration: "Integration", device: "Network device" } as const;
const linkTo = (type: string, id: number) => (type === "server" ? `/servers/${id}` : "/integrations");
const linkTo = (type: string, id: number) => (type === "server" ? `/servers/${id}` : type === "device" ? "/network/devices" : "/integrations");
/** The options of a node picker, grouped by what they are. */
function NodeSelect({ id, label, nodes, value, onChange }: { id: string; label: string; nodes: DependencyNode[]; value: string; onChange: (key: string) => void }) {
@@ -21,17 +21,18 @@ function NodeSelect({ id, label, nodes, value, onChange }: { id: string; label:
</label>
<select id={id} className="form-select" value={value} onChange={(e) => onChange(e.target.value)}>
<option value="">— choose —</option>
{(["server", "integration"] as const).map((type) => (
<optgroup key={type} label={`${TYPE_LABELS[type]}s`}>
{nodes
.filter((n) => n.type === type)
.map((n) => (
{(["server", "integration", "device"] as const).map((type) => {
const group = nodes.filter((n) => n.type === type);
return group.length === 0 ? null : (
<optgroup key={type} label={`${TYPE_LABELS[type]}s`}>
{group.map((n) => (
<option key={n.key} value={n.key}>
{n.name}
</option>
))}
</optgroup>
))}
</optgroup>
);
})}
</select>
</>
);
@@ -59,7 +60,7 @@ export default function DependencyEditor({ user }: { user: CurrentUser }) {
const parse = (key: string) => {
const [type, id] = key.split(":");
return { type: type as "server" | "integration", id: Number(id) };
return { type: type as "server" | "integration" | "device", id: Number(id) };
};
async function add(e: React.FormEvent) {
@@ -95,7 +96,7 @@ export default function DependencyEditor({ user }: { user: CurrentUser }) {
return (
<>
<p className="text-secondary">
Say what needs what: Gitea needs the server it is installed on; a Proxmox guest needs the Proxmox it runs on. When the thing that is needed is down, what needs it is down too — and its alert is
Say what needs what: Gitea needs the server it is installed on; a Proxmox guest needs the Proxmox it runs on; a server needs the switch it is plugged into. When the thing that is needed is down, what needs it is down too — and its alert is
held back under the first one on the Alerts page instead of adding to the noise. A service that was down for its own reasons still alerts once what it needs is back.
</p>
<ErrorNotice error={error} />
@@ -170,16 +171,18 @@ export default function DependencyEditor({ user }: { user: CurrentUser }) {
{data && data.runsOn.length > 0 && (
<div className="card">
<div className="card-header">
<h3 className="card-title">Servers that run on servers</h3>
<h3 className="card-title">Set elsewhere</h3>
</div>
<div className="card-body text-secondary small pb-0">
A server&rsquo;s &ldquo;runs on&rdquo; is set on the server itself, or worked out from the Proxmox node it is a guest of. A network device&rsquo;s &ldquo;connected through&rdquo; is what its UniFi controller says. They count here too.
</div>
<div className="card-body text-secondary small pb-0">These are set on each server (&ldquo;runs on&rdquo;), or worked out from the Proxmox node it is a guest of. They count here too.</div>
<div className="table-responsive">
<table className="table table-vcenter card-table">
<tbody>
{data.runsOn.map((r) => (
<tr key={`${r.from.key}>${r.to.key}`}>
<td>{r.from.name}</td>
<td className="text-secondary">runs on</td>
<td className="text-secondary">{r.from.key.startsWith("device:") && r.to.key.startsWith("device:") ? "is connected through" : "runs on"}</td>
<td>{r.to.name}</td>
</tr>
))}