Agent diagnostics ("what the agent couldn't collect") and services to ignore per server

- Agents (Linux 6, Windows 5) note each check they couldn't make and why; the server page turns that into tips and fixes, including when the agent is behind
- Linux --prepare leaves its notes for the report; a missing prepare step is itself noted
- Services to ignore are set per server from the Host health card (names or * patterns), applied on the server so alerts and /metrics drop them at once; saving alert limits keeps the list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-18 22:16:31 +02:00
1 parent b5384c1e03
commit c3bc6bbf72
26 files changed
+4118 -45

No files matched your search

+14 -1
View File
@@ -632,7 +632,7 @@ export interface AgentLatest {
/** What a Linux agent says about the machine itself. Each part is there only if the agent could find it out. */
export interface HostHealth {
failedUnits?: { unit: string; description: string }[];
failedUnits?: { unit: string; description: string; /** This server is told to ignore it: it doesn't count as failed. */ ignored?: boolean }[];
smart?: { device: string; model: string; healthy: boolean | null; temperatureC: number | null; wearPercent: number | null }[];
zfs?: { name: string; health: string; capacityPercent: number | null }[];
reportedAt: string;
@@ -655,6 +655,17 @@ export interface ServerThresholds {
diskForecastDays?: number;
backupStaleHours?: number;
mounts?: Record<string, { percent?: number; ignore?: boolean }>;
/** Services never to count as failed here: names or patterns like "gupdate*". */
ignoreServices?: string[];
}
/** One thing worth telling a person about a server's agent: what it couldn't collect (and what to do), or that it is behind. */
export interface AgentDiagnosticNote {
check: string;
level: "warning" | "info";
title: string;
fix: string | null;
detail: string | null;
}
export interface UpdateRun {
@@ -746,6 +757,8 @@ export interface ServerDetail {
links: ServerLink[];
relations: { parent: ServerRelation | null; children: ServerRelation[] };
agentLatest: AgentLatest;
/** What its agent couldn't collect, with what to do about it. */
diagnostics: AgentDiagnosticNote[];
/** The limits in Settings, which this server follows wherever it has none of its own. */
thresholdDefaults: HealthCheckSettings;
}
+39
View File
@@ -0,0 +1,39 @@
import type { AgentDiagnosticNote } from "../api/client";
/** The fixes put commands between backticks: those are shown as code. */
const withCode = (text: string) => text.split("`").map((part, i) => (i % 2 === 1 ? <code key={i}>{part}</code> : part));
/**
* What the server's agent couldn't collect, and what to do about it — the answer to "why is there no disk health here?". A tip is how this
* machine is (a virtual machine with no serial number); a warning is something to look at. Nothing to say means no card.
*/
export default function AgentDiagnostics({ notes }: { notes: AgentDiagnosticNote[] }) {
if (notes.length === 0) return null;
const warnings = notes.filter((n) => n.level === "warning").length;
return (
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">What the agent couldn&rsquo;t collect</h3>
<div className="card-actions">{warnings > 0 ? <span className="badge bg-yellow-lt text-yellow">{warnings} to look at</span> : <span className="badge bg-blue-lt text-blue">tips</span>}</div>
</div>
<div className="list-group list-group-flush">
{notes.map((n) => (
<div key={n.check + n.title} className="list-group-item">
<div className="d-flex align-items-start gap-2">
<span className={`badge ${n.level === "warning" ? "bg-yellow-lt text-yellow" : "bg-blue-lt text-blue"} flex-shrink-0 mt-1`}>{n.level === "warning" ? "look at" : "tip"}</span>
<div>
<div>{n.title}</div>
{n.detail && (
<div className="text-secondary small">
It said: <code>{n.detail}</code>
</div>
)}
{n.fix && <div className="text-secondary small">{withCode(n.fix)}</div>}
</div>
</div>
</div>
))}
</div>
</div>
);
}
+71 -9
View File
@@ -1,3 +1,4 @@
import { useState } from "react";
import type { HostHealth } from "../api/client";
import TimeAgo from "./TimeAgo";
@@ -9,18 +10,41 @@ const poolFine = (health: string) => health.toUpperCase() === "ONLINE";
* whether each storage pool (ZFS, or Storage Spaces on Windows) is online. Each part appears only if the agent reported it (no smartctl or no ZFS on the host means no part),
* and the card is left out when it has nothing to say.
*/
export default function HostHealthCard({ health }: { health: HostHealth | null }) {
if (!health) return null;
const { failedUnits, smart, zfs } = health;
export default function HostHealthCard({
health,
ignored = [],
onIgnoredChange,
}: {
health: HostHealth | null;
/** The services this server is told to ignore (names or patterns). */
ignored?: string[];
/** Given when the person can change that list; it is saved by whoever holds it. */
onIgnoredChange?: (list: string[]) => Promise<void> | void;
}) {
const [pattern, setPattern] = useState("");
const [busy, setBusy] = useState(false);
if (!health && ignored.length === 0) return null;
const { failedUnits, smart, zfs } = health ?? { failedUnits: undefined, smart: undefined, zfs: undefined, reportedAt: "" };
async function change(list: string[]) {
if (!onIgnoredChange) return;
setBusy(true);
try {
await onIgnoredChange(list);
setPattern("");
} finally {
setBusy(false);
}
}
const hasSmart = !!smart && smart.length > 0;
const hasZfs = !!zfs && zfs.length > 0;
if (failedUnits === undefined && !hasSmart && !hasZfs) return null;
if (failedUnits === undefined && !hasSmart && !hasZfs && ignored.length === 0) return null;
return (
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">Host health</h3>
{health.reportedAt && (
{health?.reportedAt && (
<div className="card-actions text-secondary small">
reported <TimeAgo value={health.reportedAt} />
</div>
@@ -30,15 +54,21 @@ export default function HostHealthCard({ health }: { health: HostHealth | null }
{failedUnits !== undefined && (
<div className={hasSmart || hasZfs ? "mb-3" : ""}>
<div className="text-secondary small mb-1">Services</div>
{failedUnits.length === 0 ? (
{failedUnits.filter((u) => !u.ignored).length === 0 ? (
<span className="badge bg-green-lt text-green">none have failed</span>
) : (
) : null}
{failedUnits.length > 0 && (
<ul className="list-unstyled mb-0">
{failedUnits.map((u) => (
<li key={u.unit}>
<span className="badge bg-red-lt text-red me-2">failed</span>
<li key={u.unit} className={u.ignored ? "text-secondary" : undefined}>
{u.ignored ? <span className="badge bg-secondary-lt text-secondary me-2">ignored</span> : <span className="badge bg-red-lt text-red me-2">failed</span>}
<code>{u.unit}</code>
{u.description && <span className="text-secondary small ms-2">{u.description}</span>}
{onIgnoredChange && !u.ignored && (
<button type="button" className="btn btn-link btn-sm p-0 ms-2 align-baseline" disabled={busy} title="Stop counting this service as failed on this server" onClick={() => void change([...ignored, u.unit])}>
Ignore
</button>
)}
</li>
))}
</ul>
@@ -46,6 +76,38 @@ export default function HostHealthCard({ health }: { health: HostHealth | null }
</div>
)}
{(ignored.length > 0 || onIgnoredChange) && (
<div className={hasSmart || hasZfs ? "mb-3" : ""}>
<div className="text-secondary small mb-1">Services this server ignores</div>
{ignored.length === 0 && <div className="text-secondary small mb-1">None. A service that always fails here (an updater, say) can be ignored, so it stops raising an alert.</div>}
<div className="d-flex flex-wrap gap-2 mb-1">
{ignored.map((p) => (
<span key={p} className="badge bg-secondary-lt text-secondary d-inline-flex align-items-center gap-1">
<code>{p}</code>
{onIgnoredChange && (
<button type="button" className="btn-close btn-close-sm" style={{ fontSize: "0.5rem" }} aria-label={`Stop ignoring ${p}`} disabled={busy} onClick={() => void change(ignored.filter((x) => x !== p))} />
)}
</span>
))}
</div>
{onIgnoredChange && (
<form
className="d-flex gap-2"
onSubmit={(e) => {
e.preventDefault();
const p = pattern.trim();
if (p && !ignored.includes(p)) void change([...ignored, p]);
}}
>
<input className="form-control form-control-sm" style={{ maxWidth: "18rem" }} aria-label="A service name or pattern to ignore" placeholder="a name, or a pattern like gupdate*" maxLength={100} value={pattern} onChange={(e) => setPattern(e.target.value)} />
<button type="submit" className="btn btn-sm" disabled={busy || pattern.trim() === ""}>
Ignore
</button>
</form>
)}
</div>
)}
{hasSmart && (
<div className={hasZfs ? "mb-3" : ""}>
<div className="text-secondary small mb-1">Disks (SMART)</div>
+4 -2
View File
@@ -13,7 +13,7 @@ const FIELDS: { key: Field; label: string; unit: string; min: number; max: numbe
{ key: "backupStaleHours", label: "Its backup is too old after", unit: "hours", min: 0, max: 2160, hint: "For the Proxmox guest this server is. 0 means it is never called stale.", onlyForGuests: true },
];
const has = (t: Thresholds | null) => !!t && (Object.keys(t).some((k) => k !== "mounts") || Object.keys(t.mounts ?? {}).length > 0);
const has = (t: Thresholds | null) => !!t && (Object.keys(t).some((k) => k !== "mounts" && k !== "ignoreServices") || Object.keys(t.mounts ?? {}).length > 0);
/**
* This server's own alert limits. Anything left empty follows Settings → Notifications, so changing the global limit still reaches every
@@ -53,6 +53,8 @@ export default function ServerThresholds({ server, defaults, disks, canEdit, onC
if (rule.percent !== undefined || rule.ignore) rules[m] = rule;
}
if (Object.keys(rules).length > 0) out.mounts = rules;
// The services to ignore are edited on the health card; saving limits here must not lose them.
if (own?.ignoreServices?.length) out.ignoreServices = own.ignoreServices;
return Object.keys(out).length > 0 ? out : null;
}
@@ -195,7 +197,7 @@ export default function ServerThresholds({ server, defaults, disks, canEdit, onC
{busy ? "Saving…" : "Save"}
</button>
{has(own) && (
<button type="button" className="btn" disabled={busy} onClick={() => void save(null)}>
<button type="button" className="btn" disabled={busy} onClick={() => void save(own?.ignoreServices?.length ? { ignoreServices: own.ignoreServices } : null)}>
Follow Settings again
</button>
)}
+22 -1
View File
@@ -19,6 +19,9 @@ import TimeAgo from "../components/TimeAgo";
import UptimeRibbon from "../components/UptimeRibbon";
import RunsOn from "../components/RunsOn";
import HostHealthCard from "../components/HostHealthCard";
import AgentDiagnostics from "../components/AgentDiagnostics";
import { toast } from "../utils/toast";
import { readableError } from "../utils/errors";
import ServerThresholds from "../components/ServerThresholds";
import RunPlaybook from "../components/RunPlaybook";
import RunbookPanel from "../components/RunbookPanel";
@@ -809,7 +812,25 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
</div>
</div>
<HostHealthCard health={server.hostHealth} />
<HostHealthCard
health={server.hostHealth}
ignored={server.thresholds?.ignoreServices ?? []}
onIgnoredChange={
isAdmin
? async (list) => {
try {
// The list is part of the server's own limits; the rest of them are carried over as they are.
await api.servers.update(server.id, { thresholds: { ...(server.thresholds ?? {}), ignoreServices: list.length > 0 ? list : undefined } });
toast.success(list.length > (server.thresholds?.ignoreServices?.length ?? 0) ? "Ignored. It no longer counts as failed on this server." : "Saved.");
void loadDetail();
} catch (err) {
toast.error(readableError(err));
}
}
: undefined
}
/>
<AgentDiagnostics notes={detail.diagnostics ?? []} />
{hardware.source === "agent" && <ServerTrends serverId={serverId} />}
<ServerThresholds key={JSON.stringify(server.thresholds)} server={server} defaults={detail.thresholdDefaults} disks={(hardware.disks ?? []).map((d) => d.mount)} canEdit={isAdmin} onChanged={() => void loadDetail()} />
{(user.role === "admin" || user.role === "operator") && <ServerActivity serverId={serverId} />}