Fold alerts under their host, recurring maintenance, run playbooks from alerts, and an Updates page

- Servers can say what they run on (or it is worked out from the Proxmox node); when the host is
  down the guests' offline alerts fold under it: held back, not counted, not notified, still recorded.
- Recurring maintenance schedules made into ordinary windows a week ahead (maintenance_schedules).
- Run a Semaphore template limited to a server from its page or an alert, and watch the run.
- Agents report pending updates (apt, dnf, zypper, Windows Update); an Updates page lists them.
- Migrations 0024 and 0025.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-17 01:35:15 +02:00
1 parent 44e393f172
commit 171511c6db
45 files changed
+6772 -44

No files matched your search

+22 -6
View File
@@ -12,6 +12,7 @@ import { readableError } from "../utils/errors";
import { ErrorNotice } from "../components/Notice";
import TableToolbar from "../components/TableToolbar";
import SilenceButton from "../components/SilenceButton";
import RunPlaybookButton from "../components/RunPlaybookButton";
const SEVERITY: Record<AlertSeverity, { label: string; badge: string; rank: number }> = {
critical: { label: "Critical", badge: "bg-red-lt text-red", rank: 0 },
@@ -89,6 +90,7 @@ export default function Alerts({ user }: { user: CurrentUser }) {
{ label: "Warnings", value: counts?.warning, color: "text-yellow" },
{ label: "Info", value: counts?.info, color: "text-blue" },
{ label: "Silenced (maintenance)", value: counts?.silenced, color: "text-secondary" },
...((counts?.grouped ?? 0) > 0 ? [{ label: "Grouped under another", value: counts?.grouped, color: "text-secondary" }] : []),
];
return (
@@ -196,10 +198,10 @@ export default function Alerts({ user }: { user: CurrentUser }) {
</option>
))}
</select>
{(counts?.silenced ?? 0) > 0 && (
{(counts?.silenced ?? 0) + (counts?.grouped ?? 0) > 0 && (
<label className="form-check mb-0">
<input type="checkbox" className="form-check-input" checked={showSilenced} onChange={(e) => setShowSilenced(e.target.checked)} />
<span className="form-check-label">Show silenced</span>
<span className="form-check-label">{(counts?.grouped ?? 0) > 0 ? "Show silenced and grouped" : "Show silenced"}</span>
</label>
)}
</>
@@ -230,10 +232,21 @@ export default function Alerts({ user }: { user: CurrentUser }) {
<td>{a.link ? <Link to={a.link}>{a.source}</Link> : a.source}</td>
<td>
{a.message}
{a.silenced && (
<span className="badge bg-secondary-lt text-secondary ms-2" title="Under a maintenance window — notifications for this are held back">
silenced
{a.causedBy ? (
<span className="badge bg-secondary-lt text-secondary ms-2" title={`${a.causedBy.name} is down too, which explains this — notifications for this are held back. If ${a.causedBy.name} comes back and this stays down, it alerts then.`}>
caused by {a.causedBy.name}
</span>
) : (
a.silenced && (
<span className="badge bg-secondary-lt text-secondary ms-2" title="Under a maintenance window — notifications for this are held back">
silenced
</span>
)
)}
{a.affects && a.affects.length > 0 && (
<div className="text-secondary small">
Also takes down {a.affects.length} {a.affects.length === 1 ? "server" : "servers"}: {a.affects.join(", ")}
</div>
)}
{a.ticket &&
(() => {
@@ -252,7 +265,10 @@ export default function Alerts({ user }: { user: CurrentUser }) {
</td>
{canSilence && (
<td className="text-nowrap">
<SilenceButton alert={a} onDone={() => void load(true)} />
<div className="btn-list flex-nowrap">
<SilenceButton alert={a} onDone={() => void load(true)} />
{a.target?.type === "server" && !a.silenced && <RunPlaybookButton serverName={a.target.name} />}
</div>
</td>
)}
</tr>
+10
View File
@@ -18,6 +18,7 @@ import { ErrorNotice } from "../components/Notice";
import { toast } from "../utils/toast";
import { confirmDialog } from "../utils/dialogs";
import MaintenanceTimeline from "../components/MaintenanceTimeline";
import RecurringMaintenance from "../components/RecurringMaintenance";
const DURATIONS: { minutes: number; label: string }[] = [
{ minutes: 30, label: "30 minutes" },
@@ -326,6 +327,15 @@ export default function Maintenance({ user }: { user: CurrentUser }) {
{((windows?.length ?? 0) > 0 || upcoming.length > 0) && <MaintenanceTimeline windows={[...(windows ?? []), ...upcoming]} now={now} />}
<RecurringMaintenance
canEdit={canEdit}
targets={targets}
onChanged={() => {
load();
announceChange();
}}
/>
{canEdit && kumaIntegrations && kumaIntegrations.length > 0 && (
<div className="card mb-3">
<div className="card-header">
+43
View File
@@ -17,6 +17,9 @@ import ServerTrends from "../components/ServerTrends";
import ServerActivity from "../components/ServerActivity";
import TimeAgo from "../components/TimeAgo";
import UptimeRibbon from "../components/UptimeRibbon";
import RunsOn from "../components/RunsOn";
import RunPlaybook from "../components/RunPlaybook";
import UpdatesBadge from "../components/UpdatesBadge";
import ServerTags from "../components/ServerTags";
import ServerTaskTable, { SCHEDULE_TYPE_LABELS } from "../components/ServerTaskTable";
import { formatDateTime } from "../utils/date";
@@ -755,6 +758,36 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
<dd className="col-7">
<UptimeRibbon kind="servers" id={server.id} name={server.name} />
</dd>
<dt className="col-5">Runs on</dt>
<dd className="col-7">
<RunsOn serverId={server.id} parent={detail.relations.parent} canEdit={isAdmin} onChanged={() => void loadDetail()} />
</dd>
{detail.relations.children.length > 0 && (
<>
<dt className="col-5">Runs here</dt>
<dd className="col-7">
{detail.relations.children.map((c, i) => (
<span key={c.id}>
{i > 0 && ", "}
<Link to={`/servers/${c.id}`}>{c.name}</Link>
</span>
))}
</dd>
</>
)}
{server.lastSeenAt && (
<>
<dt className="col-5">Updates</dt>
<dd className="col-7">
<UpdatesBadge updates={server.pendingUpdates} />
{server.updatesPendingSince && server.pendingUpdates && server.pendingUpdates.count > 0 && (
<div className="text-secondary small">
waiting since <TimeAgo value={server.updatesPendingSince} />
</div>
)}
</dd>
</>
)}
</dl>
</div>
</div>
@@ -763,6 +796,16 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
{hardware.source === "agent" && <ServerTrends serverId={serverId} />}
{(user.role === "admin" || user.role === "operator") && <ServerActivity serverId={serverId} />}
{canEditTasks && (
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">Run a playbook</h3>
</div>
<div className="card-body">
<RunPlaybook serverName={server.name} defaultLimit={server.name} />
</div>
</div>
)}
<ServerPorts
serverId={serverId}
+244
View File
@@ -0,0 +1,244 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type DockhandContainer, type UpdatesServer } from "../api/client";
import SortableTh from "../components/SortableTh";
import TableToolbar from "../components/TableToolbar";
import TimeAgo from "../components/TimeAgo";
import UpdatesBadge from "../components/UpdatesBadge";
import { BlockSkeleton } from "../components/Skeleton";
import { ErrorNotice } from "../components/Notice";
import { useSortable } from "../hooks/useSortable";
import { useTableSearch } from "../hooks/useTableSearch";
import { downloadCsv } from "../utils/csv";
import { readableError } from "../utils/errors";
interface Row {
id: number;
name: string;
os: string;
manager: string;
/** Null: the agent hasn't said. */
count: number | null;
security: number | null;
restart: boolean;
/** ISO — when updates were first seen waiting. */
since: string | null;
reportedAt: string | null;
server: UpdatesServer;
}
function toRow(s: UpdatesServer): Row {
return {
id: s.id,
name: s.name,
os: s.osType,
manager: s.updates?.manager ?? "",
count: s.updates ? s.updates.count : null,
security: s.updates ? s.updates.security : null,
restart: s.updates?.rebootRequired ?? false,
since: s.pendingSince,
reportedAt: s.updates?.reportedAt || null,
server: s,
};
}
const DAY_MS = 86_400_000;
/**
* What is waiting to be installed, in one place: the updates each server's agent says are pending (how many, how many are security fixes,
* whether a restart is due, and how long they have been waiting) and the Docker containers that have a newer image. It only looks —
* nothing here installs anything.
*/
export default function Updates() {
const [servers, setServers] = useState<UpdatesServer[] | null>(null);
const [containers, setContainers] = useState<(DockhandContainer & { integrationName: string })[] | null>(null);
const [error, setError] = useState<string | null>(null);
const [onlyWaiting, setOnlyWaiting] = useState(false);
useEffect(() => {
let alive = true;
api.servers
.updates()
.then((res) => alive && setServers(res.servers))
.catch((err) => alive && setError(readableError(err)));
api.integrations
.list()
.then(async (res) => {
const docker = res.integrations.filter((i) => i.type === "dockhand" && i.enabled);
const all = await Promise.all(
docker.map((i) =>
api.integrations.dockhand
.containers(i.id)
.then((r) => r.containers.map((c) => ({ ...c, integrationName: i.name })))
.catch(() => []),
),
);
if (alive) setContainers(docker.length === 0 ? null : all.flat().filter((c) => c.updateAvailable === true));
})
.catch(() => {});
return () => {
alive = false;
};
}, []);
const rows = (servers ?? []).map(toRow);
const waiting = rows.filter((r) => (r.count ?? 0) > 0);
const tableSearch = useTableSearch(onlyWaiting ? waiting : rows);
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered, "security", "desc", { url: true });
const reporting = rows.filter((r) => r.count !== null).length;
const securityTotal = rows.reduce((n, r) => n + (r.security ?? 0), 0);
const restarts = rows.filter((r) => r.restart).length;
const oldest = waiting.map((r) => r.since).filter((s): s is string => !!s).sort()[0];
const notReporting = rows.length - reporting;
function exportCsv() {
if (!sorted) return;
downloadCsv(
"updates.csv",
["Server", "Package manager", "Waiting", "Security", "Restart needed", "Waiting since", "Reported"],
sorted.map((r) => [r.name, r.manager, r.count ?? "", r.security ?? "", r.restart ? "yes" : "no", r.since ?? "", r.reportedAt ?? ""]),
);
}
const cards: { label: string; value: string | number; note?: string; color: string }[] = [
{ label: "Servers with updates waiting", value: servers ? `${waiting.length} of ${reporting}` : "…", note: notReporting > 0 ? `${notReporting} haven't reported updates` : undefined, color: waiting.length > 0 ? "text-yellow" : "text-green" },
{ label: "Security updates waiting", value: servers ? securityTotal : "…", color: securityTotal > 0 ? "text-red" : "text-green" },
{ label: "Need a restart", value: servers ? restarts : "…", color: restarts > 0 ? "text-orange" : "text-green" },
{ label: "Longest wait", value: oldest ? `${Math.max(1, Math.floor((Date.now() - Date.parse(oldest)) / DAY_MS))} d` : servers ? "—" : "…", color: "text-secondary" },
];
return (
<>
<div className="d-flex align-items-center mb-3">
<h2 className="page-title mb-0">Updates</h2>
</div>
<p className="text-secondary">
What the agents say is waiting to be installed on each server, and the Docker containers that have a newer image. This page only looks — it installs nothing. To apply updates, run a playbook from the server's page.
</p>
<ErrorNotice error={error} />
<div className="row row-cards mb-3">
{cards.map((c) => (
<div className="col-6 col-lg-3" key={c.label}>
<div className="card card-sm">
<div className="card-body">
<div className={`h2 mb-0 ${c.color}`}>{c.value}</div>
<div className="text-secondary">{c.label}</div>
{c.note && <div className="text-secondary small">{c.note}</div>}
</div>
</div>
</div>
))}
</div>
<div className="card mb-3">
<TableToolbar
search={tableSearch.query}
onSearch={tableSearch.setQuery}
placeholder="Search servers…"
filters={
<label className="form-check mb-0">
<input type="checkbox" className="form-check-input" checked={onlyWaiting} onChange={(e) => setOnlyWaiting(e.target.checked)} />
<span className="form-check-label">Only those with updates</span>
</label>
}
shown={sorted?.length}
total={onlyWaiting ? waiting.length : rows.length}
onExport={exportCsv}
exportDisabled={!sorted || sorted.length === 0}
/>
<div className="table-responsive">
<table className="table table-vcenter card-table">
<thead>
<tr>
<SortableTh<Row> label="Server" sortKeyName="name" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Updates" sortKeyName="count" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Security" sortKeyName="security" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Waiting since" sortKeyName="since" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Reported" sortKeyName="reportedAt" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
</tr>
</thead>
<tbody>
{servers === null && !error && (
<tr>
<td colSpan={5}>
<BlockSkeleton lines={3} />
</td>
</tr>
)}
{sorted?.map((r) => (
<tr key={r.id}>
<td>
<Link to={`/servers/${r.id}`}>{r.name}</Link> <span className="text-secondary small">{r.manager}</span>
</td>
<td>
<UpdatesBadge updates={r.server.updates} />
</td>
<td>{r.security === null ? <span className="text-secondary">—</span> : r.security}</td>
<td className="text-secondary">{r.since ? <TimeAgo value={r.since} /> : "—"}</td>
<td className="text-secondary">{r.reportedAt ? <TimeAgo value={r.reportedAt} /> : "—"}</td>
</tr>
))}
{servers !== null && sorted?.length === 0 && (
<tr>
<td colSpan={5} className="text-secondary text-center">
{tableSearch.active || onlyWaiting ? "Nothing matches that." : "No server has reported yet."}
</td>
</tr>
)}
</tbody>
</table>
</div>
{notReporting > 0 && (
<div className="card-footer text-secondary small">
“Not reported” means that server's agent hasn't said — it may be an older agent (run its install command again, from Servers → Manage servers, to update it), or its package manager isn't apt, dnf, zypper or Windows Update.
</div>
)}
</div>
{containers !== null && (
<div className="card">
<div className="card-header">
<h3 className="card-title">Docker containers with a newer image</h3>
</div>
<div className="table-responsive">
<table className="table table-vcenter card-table">
<thead>
<tr>
<th>Container</th>
<th>Image</th>
<th>Newer version</th>
<th>Where</th>
<th>Checked</th>
</tr>
</thead>
<tbody>
{containers.map((c) => (
<tr key={`${c.integrationName}:${c.environmentId}:${c.id}`}>
<td>
<Link to="/docker">{c.name}</Link>
</td>
<td className="text-secondary">{c.image}</td>
<td>{c.newerVersion ?? "—"}</td>
<td className="text-secondary">{c.environmentName}</td>
<td className="text-secondary">
<TimeAgo value={c.checkedAt} />
</td>
</tr>
))}
{containers.length === 0 && (
<tr>
<td colSpan={5} className="text-secondary text-center">
Every container is on its latest image, as far as the last check could tell.
</td>
</tr>
)}
</tbody>
</table>
</div>
</div>
)}
</>
);
}