Endpoint checks, restore tests, and a change log

- Endpoints: HTTP, TCP and TLS checks with answer time, uptime and certificate expiry; failures and expiring certificates become alerts and notifications; linked to a server for maintenance and tags
- Restore tests: record when a backup was restored and how it went; failed tests always alert, overdue ones with a limit set; shown on the Backup coverage page
- Change log: one filterable timeline made from the audit log and the incident record

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-18 23:03:56 +02:00
1 parent c3bc6bbf72
commit 92726568b7
37 files changed
+6918 -21

No files matched your search

+5 -1
View File
@@ -34,6 +34,8 @@ import IncidentDetail from "./pages/IncidentDetail";
import Inventory from "./pages/Inventory";
import InventoryLabels from "./pages/InventoryLabels";
import Dependencies from "./pages/Dependencies";
import Endpoints from "./pages/Endpoints";
import ChangeLog from "./pages/ChangeLog";
import Backups from "./pages/Backups";
import Domains from "./pages/Domains";
import Consistency from "./pages/Consistency";
@@ -151,7 +153,9 @@ function Shelled({ user }: { user: CurrentUser }) {
<Route path="/inventory" element={<Inventory user={user} />} />
<Route path="/inventory/labels" element={<InventoryLabels />} />
<Route path="/dependencies" element={<Dependencies user={user} />} />
<Route path="/backups" element={<Backups />} />
<Route path="/endpoints" element={<Endpoints user={user} />} />
<Route path="/changes" element={user.role === "viewer" ? <Navigate to="/" replace /> : <ChangeLog />} />
<Route path="/backups" element={<Backups user={user} />} />
<Route path="/docker" element={<Docker user={user} />} />
<Route path="/tailscale" element={<Tailscale user={user} />} />
<Route path="/semaphore" element={<Semaphore user={user} />} />
+106
View File
@@ -497,6 +497,8 @@ export interface HealthCheckSettings {
diskForecastDays: number;
/** A Proxmox guest whose newest backup is older than this many hours is raised as stale; 0 is off. */
backupStaleHours: number;
/** A restore test older than this many days is a problem; 0 = off (a failed test always is). */
restoreTestDays: number;
}
export interface QuietHoursSettings {
@@ -810,9 +812,34 @@ export interface CoverageGuest {
status: CoverageStatus;
failure: string | null;
server: { id: number; name: string } | null;
/** The key a restore test of this guest is recorded under. */
restoreKey?: string;
/** How the newest restore test of it went. */
restoreTest?: RestoreInfo;
}
export type RestoreResult = "ok" | "partial" | "failed" | "not_needed";
export type RestoreStatus = RestoreResult | "never" | "stale";
export interface RestoreInfo {
status: RestoreStatus;
testedAt: string | null;
ageDays: number | null;
note: string | null;
testedBy: string | null;
}
export interface RestoreTestEntry {
id: number;
subjectKey: string;
label: string;
testedAt: string;
result: RestoreResult;
note: string | null;
testedBy: string | null;
createdAt: string;
}
export interface BackupCoverage {
restoreTestDays?: number;
guests: CoverageGuest[];
counts: Record<CoverageStatus, number> & { total: number };
sources: { kind: "proxmox" | "pbs"; name: string; ok: boolean; error?: string }[];
@@ -820,6 +847,68 @@ export interface BackupCoverage {
generatedAt: string;
}
export type EndpointKind = "http" | "tcp" | "tls";
export interface EndpointStats {
uptime24h: number | null;
uptime7d: number | null;
avgMs24h: number | null;
recent: { at: string; ok: boolean; ms: number | null }[];
}
export interface EndpointCheck {
id: number;
name: string;
kind: EndpointKind;
target: string;
port: number | null;
expectStatus: string | null;
keyword: string | null;
insecure: boolean;
intervalMinutes: number;
timeoutSeconds: number;
failuresBeforeAlert: number;
warnDays: number;
serverId: number | null;
enabled: boolean;
lastCheckedAt: string | null;
lastOk: boolean | null;
lastMessage: string | null;
lastResponseMs: number | null;
certExpiresAt: string | null;
consecutiveFailures: number;
lastChangeAt: string | null;
server: { id: number; name: string } | null;
stats?: EndpointStats;
}
export interface EndpointInput {
name: string;
kind: EndpointKind;
target: string;
port?: number | null;
expectStatus?: string | null;
keyword?: string | null;
insecure?: boolean;
intervalMinutes?: number;
timeoutSeconds?: number;
failuresBeforeAlert?: number;
warnDays?: number;
serverId?: number | null;
enabled?: boolean;
}
export type ChangeKind = "servers" | "maintenance" | "alerts" | "settings" | "integrations" | "dependencies" | "inventory" | "backups" | "endpoints" | "other";
export interface ChangeEntry {
id: string;
at: string;
kind: ChangeKind;
tone: "good" | "bad" | "neutral" | "info";
title: string;
detail: string | null;
actor: string | null;
target: { type: string; id: string | null; name: string | null } | null;
link: string | null;
serverId: number | null;
}
export type AssetKind = "server" | "storage" | "network" | "power" | "client" | "other";
export type DependencyNodeType = "server" | "integration";
@@ -1757,6 +1846,23 @@ export const api = {
},
backups: {
coverage: (staleDays: number, refresh = false) => request<BackupCoverage>(`/api/backups/coverage?staleDays=${staleDays}${refresh ? "&refresh=1" : ""}`),
restoreTests: () => request<{ limitDays: number; tests: RestoreTestEntry[]; custom: (RestoreInfo & { key: string; label: string })[] }>("/api/backups/restore-tests"),
recordRestoreTest: (data: { key?: string; label: string; testedAt?: string; result: RestoreResult; note?: string }) => request<{ test: RestoreTestEntry }>("/api/backups/restore-tests", { method: "POST", body: JSON.stringify(data) }),
removeRestoreTest: (id: number) => request<void>(`/api/backups/restore-tests/${id}`, { method: "DELETE" }),
},
endpoints: {
list: () => request<{ checks: EndpointCheck[]; servers: { id: number; name: string }[] }>("/api/endpoints"),
create: (data: EndpointInput) => request<{ check: EndpointCheck }>("/api/endpoints", { method: "POST", body: JSON.stringify(data) }),
update: (id: number, data: EndpointInput) => request<{ check: EndpointCheck }>(`/api/endpoints/${id}`, { method: "PUT", body: JSON.stringify(data) }),
remove: (id: number) => request<void>(`/api/endpoints/${id}`, { method: "DELETE" }),
check: (id: number) => request<{ result: { ok: boolean; ms: number | null; message: string } }>(`/api/endpoints/${id}/check`, { method: "POST" }),
},
changes: {
list: (params: { days?: number; kind?: string; serverId?: number; q?: string; before?: string; limit?: number }) => {
const q = new URLSearchParams();
for (const [k, v] of Object.entries(params)) if (v !== undefined && v !== "") q.set(k, String(v));
return request<{ entries: ChangeEntry[]; more: boolean; kinds: { id: ChangeKind; label: string }[] }>(`/api/changes?${q.toString()}`);
},
},
push: {
key: () => request<{ publicKey: string }>("/api/push/key"),
+6
View File
@@ -1,4 +1,5 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { IconAlertTriangle, IconCircleCheck, IconEdit, IconTool } from "@tabler/icons-react";
import { api, type ServerActivityEvent } from "../api/client";
import { formatDateTime } from "../utils/date";
@@ -39,6 +40,11 @@ export default function ServerActivity({ serverId }: { serverId: number }) {
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">Activity</h3>
<div className="card-actions">
<Link to={`/changes?serverId=${serverId}&days=90`} className="small">
Everything about this server in the change log
</Link>
</div>
</div>
<div className="card-body">
{failed ? (
+4
View File
@@ -26,6 +26,8 @@ import {
IconDownload,
IconBox,
IconHierarchy2,
IconHeartbeat,
IconGitCommit,
IconShieldCheck,
IconActivityHeartbeat,
IconCopyCheck,
@@ -89,6 +91,7 @@ export const NAV: NavEntry[] = [
{ to: "/domains", label: "Domains", icon: <IconWorldWww size={20} /> },
{ to: "/ipam", label: "IP Addresses", icon: <IconNetwork size={20} /> },
{ to: "/ports", label: "Ports", icon: <IconPlug size={20} /> },
{ to: "/endpoints", label: "Endpoints", icon: <IconHeartbeat size={20} /> },
{ to: "/consistency", label: "Consistency", icon: <IconListCheck size={20} /> },
],
},
@@ -109,6 +112,7 @@ export const NAV: NavEntry[] = [
items: [
{ to: "/alerts", label: "Alerts", icon: <IconAlertTriangle size={20} /> },
{ to: "/incidents", label: "Incidents", icon: <IconTimeline size={20} /> },
{ to: "/changes", label: "Change log", icon: <IconGitCommit size={20} />, minRole: "operator" },
{ to: "/maintenance", label: "Maintenance", icon: <IconTool size={20} /> },
{ to: "/updates", label: "Updates", icon: <IconDownload size={20} /> },
{ to: "/uptime-kuma", label: "Uptime Kuma", icon: <IconActivityHeartbeat size={20} /> },
+222 -6
View File
@@ -1,6 +1,8 @@
import { useEffect, useState } from "react";
import { Link, useSearchParams } from "react-router-dom";
import { api, type BackupCoverage, type CoverageGuest, type CoverageStatus } from "../api/client";
import { api, type BackupCoverage, type CoverageGuest, type CoverageStatus, type CurrentUser, type RestoreInfo, type RestoreResult, type RestoreStatus, type RestoreTestEntry } from "../api/client";
import { confirmDialog } from "../utils/dialogs";
import { toast } from "../utils/toast";
import Pagination from "../components/Pagination";
import SortableTh from "../components/SortableTh";
import TableToolbar from "../components/TableToolbar";
@@ -30,11 +32,79 @@ const STATUS: Record<CoverageStatus, { label: string; badge: string; hint: strin
const STALE_CHOICES = [1, 2, 3, 7, 14];
const RESTORE: Record<RestoreStatus, { label: string; badge: string }> = {
never: { label: "Never tested", badge: "bg-secondary-lt text-secondary" },
ok: { label: "Restored fine", badge: "bg-green-lt text-green" },
partial: { label: "Partly worked", badge: "bg-yellow-lt text-yellow" },
failed: { label: "Restore failed", badge: "bg-red-lt text-red" },
stale: { label: "Test is old", badge: "bg-yellow-lt text-yellow" },
not_needed: { label: "No need to test", badge: "bg-secondary-lt text-secondary" },
};
const RESULT_WORDS: Record<RestoreResult, string> = { ok: "It restored and worked", partial: "It restored, but not everything worked", failed: "It failed", not_needed: "No need to test this one" };
interface TestDraft {
/** A guest's key, or null for something that isn't a Proxmox guest. */
key: string | null;
label: string;
testedAt: string;
result: RestoreResult;
note: string;
}
const todayIso = () => new Date().toISOString().slice(0, 10);
const ageWords = (r: RestoreInfo) => (r.ageDays === null ? "" : r.ageDays === 0 ? "today" : r.ageDays === 1 ? "yesterday" : `${r.ageDays} days ago`);
/**
* What is and isn't backed up: every Proxmox guest, whether a backup job covers it, when it was last backed up (from Proxmox Backup Server
* snapshots and Proxmox's own backup tasks), and whether that went well — one page instead of an alert per gap.
*/
export default function Backups() {
export default function Backups({ user }: { user?: CurrentUser }) {
const canRecord = user?.role === "admin" || user?.role === "operator";
const isAdmin = user?.role === "admin";
const [tests, setTests] = useState<RestoreTestEntry[] | null>(null);
const [custom, setCustom] = useState<(RestoreInfo & { key: string; label: string })[]>([]);
const [draft, setDraft] = useState<TestDraft | null>(null);
const [saving, setSaving] = useState(false);
function loadTests() {
api.backups
.restoreTests()
.then((res) => {
setTests(res.tests);
setCustom(res.custom);
})
.catch(() => setTests([]));
}
useEffect(loadTests, []);
async function saveTest(e: React.FormEvent) {
e.preventDefault();
if (!draft) return;
setSaving(true);
try {
await api.backups.recordRestoreTest({ key: draft.key ?? undefined, label: draft.label.trim(), testedAt: draft.testedAt, result: draft.result, note: draft.note.trim() || undefined });
toast.success("Recorded.");
setDraft(null);
loadTests();
load();
} catch (err) {
setError(readableError(err));
} finally {
setSaving(false);
}
}
async function removeTest(t: RestoreTestEntry) {
if (!(await confirmDialog({ title: "Remove a restore test", message: `Remove the test of "${t.label}" from ${t.testedAt}?`, confirmLabel: "Remove", danger: true }))) return;
try {
await api.backups.removeRestoreTest(t.id);
loadTests();
load();
} catch (err) {
setError(readableError(err));
}
}
const [params, setParams] = useSearchParams();
const staleParam = Number(params.get("stale"));
const staleDays = STALE_CHOICES.includes(staleParam) ? staleParam : 2;
@@ -83,8 +153,8 @@ export default function Backups() {
if (!sorted) return;
downloadCsv(
"backup-coverage.csv",
["Guest", "Type", "ID", "Node", "Cluster", "In a backup job", "Last backup", "Source", "Status", "Problem"],
sorted.map((r) => [r.name, r.type === "qemu" ? "VM" : "Container", r.vmid, r.node, r.integrationName, r.inJob ? "yes" : "no", r.lastBackupAt ?? "", r.lastSource === "pbs" ? "Backup Server" : r.lastSource === "task" ? "Proxmox task" : "", STATUS[r.status].label, r.failure ?? ""]),
["Guest", "Type", "ID", "Node", "Cluster", "In a backup job", "Last backup", "Source", "Status", "Problem", "Restore test", "Tested on"],
sorted.map((r) => [r.name, r.type === "qemu" ? "VM" : "Container", r.vmid, r.node, r.integrationName, r.inJob ? "yes" : "no", r.lastBackupAt ?? "", r.lastSource === "pbs" ? "Backup Server" : r.lastSource === "task" ? "Proxmox task" : "", STATUS[r.status].label, r.failure ?? "", r.restoreTest ? RESTORE[r.restoreTest.status].label : "", r.restoreTest?.testedAt ?? ""]),
);
}
@@ -168,12 +238,13 @@ export default function Backups() {
<SortableTh<Row> label="In a job" sortKeyName="inJob" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Last backup" sortKeyName="lastBackupAt" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Status" sortKeyName="rank" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<th>Restore test</th>
</tr>
</thead>
<tbody>
{report === null && !error && (
<tr>
<td colSpan={4}>
<td colSpan={5}>
<BlockSkeleton lines={4} />
</td>
</tr>
@@ -209,11 +280,28 @@ export default function Backups() {
</span>
{r.failure && <div className="text-secondary small">{r.failure}</div>}
</td>
<td>
{r.restoreTest && (
<>
<span className={`badge ${RESTORE[r.restoreTest.status].badge}`} title={r.restoreTest.note ?? undefined}>
{RESTORE[r.restoreTest.status].label}
</span>
{r.restoreTest.testedAt && <div className="text-secondary small">{ageWords(r.restoreTest)}</div>}
</>
)}
{canRecord && r.restoreKey && (
<div>
<button type="button" className="btn btn-link btn-sm p-0" onClick={() => setDraft({ key: r.restoreKey!, label: r.name, testedAt: todayIso(), result: "ok", note: "" })}>
Record a test
</button>
</div>
)}
</td>
</tr>
))}
{report !== null && sorted?.length === 0 && (
<tr>
<td colSpan={4} className="text-secondary text-center">
<td colSpan={5} className="text-secondary text-center">
{rows.length === 0 ? (
<>
No Proxmox guests to show. Connect a Proxmox integration under <Link to="/integrations">Integrations</Link>.
@@ -233,6 +321,134 @@ export default function Backups() {
name its guests, so a guest backed up to something other than a Backup Server reads “Unknown” rather than being guessed at. The result is kept for a minute; “Check now” asks again.
</div>
</div>
{draft && (
<form className="card mt-3" onSubmit={saveTest}>
<div className="card-header">
<h3 className="card-title">Record a restore test{draft.key ? ` of ${draft.label}` : ""}</h3>
</div>
<div className="card-body row g-3">
{draft.key === null && (
<div className="col-md-5">
<label className="form-label" htmlFor="rt-label">
What was restored
</label>
<input id="rt-label" className="form-control" required maxLength={120} placeholder="e.g. Photos share, Gitea database" value={draft.label} onChange={(e) => setDraft({ ...draft, label: e.target.value })} />
</div>
)}
<div className="col-md-3">
<label className="form-label" htmlFor="rt-date">
On
</label>
<input id="rt-date" type="date" className="form-control" required max={todayIso()} value={draft.testedAt} onChange={(e) => setDraft({ ...draft, testedAt: e.target.value })} />
</div>
<div className="col-md-4">
<label className="form-label" htmlFor="rt-result">
How it went
</label>
<select id="rt-result" className="form-select" value={draft.result} onChange={(e) => setDraft({ ...draft, result: e.target.value as RestoreResult })}>
{(Object.keys(RESULT_WORDS) as RestoreResult[]).map((r) => (
<option key={r} value={r}>
{RESULT_WORDS[r]}
</option>
))}
</select>
</div>
<div className="col-12">
<label className="form-label" htmlFor="rt-note">
Note (optional)
</label>
<input id="rt-note" className="form-control" maxLength={500} placeholder="e.g. restored to a scratch VM, booted, the database was there" value={draft.note} onChange={(e) => setDraft({ ...draft, note: e.target.value })} />
</div>
</div>
<div className="card-footer d-flex gap-2">
<button type="submit" className="btn btn-primary" disabled={saving || draft.label.trim() === ""}>
{saving ? "Saving…" : "Record it"}
</button>
<button type="button" className="btn" onClick={() => setDraft(null)}>
Cancel
</button>
</div>
</form>
)}
<div className="card mt-3">
<div className="card-header">
<h3 className="card-title">Restore tests</h3>
{canRecord && !draft && (
<div className="card-actions">
<button className="btn btn-sm" onClick={() => setDraft({ key: null, label: "", testedAt: todayIso(), result: "ok", note: "" })}>
Record a test of something else
</button>
</div>
)}
</div>
<div className="card-body text-secondary small pb-0">
A backup nobody has restored is a hope, not a backup. Record each time you try one — for a guest above, or for anything else (a share, a database). A failed test is raised on the
Alerts page; under Settings → Notifications you can also ask to be reminded when a guest with backups hasn&rsquo;t had one in a while{report?.restoreTestDays ? ` (now: ${report.restoreTestDays} days)` : ""}.
</div>
{custom.length > 0 && (
<div className="card-body pb-0">
<div className="text-secondary small mb-1">Other things being tracked</div>
<div className="d-flex flex-wrap gap-2">
{custom.map((c) => (
<span key={c.key} className={`badge ${RESTORE[c.status].badge}`}>
{c.label} · {RESTORE[c.status].label.toLowerCase()} {ageWords(c)}
</span>
))}
</div>
</div>
)}
<div className="table-responsive">
<table className="table table-vcenter card-table table-stack">
<thead>
<tr>
<th>Date</th>
<th>What</th>
<th>Result</th>
<th>Note</th>
{isAdmin && <th className="w-1">Actions</th>}
</tr>
</thead>
<tbody>
{tests === null && (
<tr>
<td colSpan={isAdmin ? 5 : 4}>
<BlockSkeleton lines={2} />
</td>
</tr>
)}
{tests?.map((t) => (
<tr key={t.id}>
<td className="stack-label" data-label="Date">{t.testedAt}</td>
<td>{t.label}</td>
<td>
<span className={`badge ${RESTORE[t.result].badge}`}>{RESTORE[t.result].label}</span>
</td>
<td className="text-secondary stack-wide">
{t.note ?? "—"}
{t.testedBy && <span className="small"> · {t.testedBy}</span>}
</td>
{isAdmin && (
<td className="stack-wide">
<button className="btn btn-sm btn-outline-danger" onClick={() => void removeTest(t)}>
Remove
</button>
</td>
)}
</tr>
))}
{tests !== null && tests.length === 0 && (
<tr>
<td colSpan={isAdmin ? 5 : 4} className="text-secondary text-center">
No restore has been recorded yet.{canRecord ? " After you next try one, record it here." : ""}
</td>
</tr>
)}
</tbody>
</table>
</div>
</div>
</>
);
}
+209
View File
@@ -0,0 +1,209 @@
import { useEffect, useState } from "react";
import { Link, useSearchParams } from "react-router-dom";
import { api, type ChangeEntry, type ChangeKind } from "../api/client";
import { ErrorNotice } from "../components/Notice";
import { BlockSkeleton } from "../components/Skeleton";
import { downloadCsv } from "../utils/csv";
import { formatDate, formatTime } from "../utils/date";
import { readableError } from "../utils/errors";
const TONE_DOT: Record<ChangeEntry["tone"], string> = { good: "#2fb344", bad: "#e05252", info: "#4299e1", neutral: "#8a94a6" };
const RANGES: { days: number; label: string }[] = [
{ days: 1, label: "Last 24 hours" },
{ days: 7, label: "Last 7 days" },
{ days: 30, label: "Last 30 days" },
{ days: 90, label: "Last 90 days" },
{ days: 400, label: "Everything kept" },
];
const PAGE = 100;
/**
* What has changed, in one list: agents updated, settings changed, maintenance started, dependencies edited, alerts raised and cleared — each as a
* sentence, newest first, grouped by day. Narrow it to a kind of change, a server, a stretch of time or a word. The Audit Log is the raw table behind it.
*/
export default function ChangeLog() {
const [params, setParams] = useSearchParams();
const days = RANGES.some((r) => r.days === Number(params.get("days"))) ? Number(params.get("days")) : 7;
const kind = params.get("kind") ?? "";
const serverId = /^\d+$/.test(params.get("serverId") ?? "") ? Number(params.get("serverId")) : undefined;
const q = params.get("q") ?? "";
const [text, setText] = useState(q);
const [entries, setEntries] = useState<ChangeEntry[] | null>(null);
const [more, setMore] = useState(false);
const [kinds, setKinds] = useState<{ id: ChangeKind; label: string }[]>([]);
const [servers, setServers] = useState<{ id: number; name: string }[]>([]);
const [error, setError] = useState<string | null>(null);
const [loadingMore, setLoadingMore] = useState(false);
const setParam = (key: string, value: string | null) =>
setParams(
(prev) => {
const next = new URLSearchParams(prev);
if (value) next.set(key, value);
else next.delete(key);
return next;
},
{ replace: true },
);
useEffect(() => {
api.servers
.list()
.then((res) => setServers(res.servers.map((s) => ({ id: s.id, name: s.name })).sort((a, b) => a.name.localeCompare(b.name))))
.catch(() => {});
}, []);
// What is searched for follows what is typed, a moment after it stops.
useEffect(() => {
const t = setTimeout(() => setParam("q", text.trim() || null), 300);
return () => clearTimeout(t);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [text]);
useEffect(() => {
let alive = true;
setEntries(null);
api.changes
.list({ days, kind, serverId, q, limit: PAGE })
.then((res) => {
if (!alive) return;
setEntries(res.entries);
setMore(res.more);
setKinds(res.kinds);
setError(null);
})
.catch((err) => alive && setError(readableError(err)));
return () => {
alive = false;
};
}, [days, kind, serverId, q]);
async function older() {
if (!entries || entries.length === 0) return;
setLoadingMore(true);
try {
const res = await api.changes.list({ days, kind, serverId, q, limit: PAGE, before: entries[entries.length - 1].at });
setEntries([...entries, ...res.entries]);
setMore(res.more);
} catch (err) {
setError(readableError(err));
} finally {
setLoadingMore(false);
}
}
// Grouped by the day it happened (in this browser's time).
const days_: { day: string; items: ChangeEntry[] }[] = [];
for (const e of entries ?? []) {
const day = formatDate(new Date(e.at));
const last = days_[days_.length - 1];
if (last && last.day === day) last.items.push(e);
else days_.push({ day, items: [e] });
}
function exportCsv() {
downloadCsv(
"change-log.csv",
["When", "Kind", "What", "Details", "By", "About"],
(entries ?? []).map((e) => [e.at, kinds.find((k) => k.id === e.kind)?.label ?? e.kind, e.title, e.detail ?? "", e.actor ?? "", e.target?.name ?? ""]),
);
}
return (
<>
<div className="d-flex flex-wrap align-items-center gap-2 mb-1">
<h2 className="page-title mb-0">Change log</h2>
<button className="btn btn-outline-secondary ms-auto" onClick={exportCsv} disabled={!entries || entries.length === 0}>
Export CSV
</button>
</div>
<p className="text-secondary">
What changed and when: agents updated, settings changed, maintenance started and ended, dependencies edited, alerts raised and cleared. The <Link to="/audit-log">Audit Log</Link> is the raw table behind it.
</p>
<ErrorNotice error={error} />
<div className="card mb-3">
<div className="card-body d-flex flex-wrap gap-2 align-items-center">
<input className="form-control w-auto flex-grow-1" style={{ maxWidth: "22rem" }} type="search" aria-label="Search the change log" placeholder="Search: a server, a person, a word…" value={text} onChange={(e) => setText(e.target.value)} />
<select className="form-select w-auto" aria-label="Kind of change" value={kind} onChange={(e) => setParam("kind", e.target.value || null)}>
<option value="">All kinds</option>
{kinds.map((k) => (
<option key={k.id} value={k.id}>
{k.label}
</option>
))}
</select>
<select className="form-select w-auto" aria-label="Server" value={serverId ?? ""} onChange={(e) => setParam("serverId", e.target.value || null)}>
<option value="">Every server</option>
{servers.map((s) => (
<option key={s.id} value={s.id}>
{s.name}
</option>
))}
</select>
<select className="form-select w-auto" aria-label="How far back" value={days} onChange={(e) => setParam("days", e.target.value === "7" ? null : e.target.value)}>
{RANGES.map((r) => (
<option key={r.days} value={r.days}>
{r.label}
</option>
))}
</select>
</div>
</div>
{entries === null && !error && <BlockSkeleton lines={5} />}
{entries !== null && entries.length === 0 && (
<div className="card">
<div className="card-body text-secondary text-center">
Nothing {q || kind || serverId ? "matches that" : "has changed"} in {RANGES.find((r) => r.days === days)?.label.toLowerCase()}.
{(q || kind || serverId || days < 400) && " Try a wider range or fewer filters."}
</div>
</div>
)}
{days_.map((group) => (
<div className="card mb-3" key={group.day}>
<div className="card-header">
<h3 className="card-title">{group.day}</h3>
</div>
<div className="list-group list-group-flush">
{group.items.map((e) => (
<div className="list-group-item" key={e.id}>
<div className="d-flex gap-3">
<span className="flex-shrink-0 text-secondary small text-nowrap" style={{ width: "3.2rem" }}>
{formatTime(new Date(e.at), false)}
</span>
<span aria-hidden="true" className="flex-shrink-0 mt-2" style={{ width: 8, height: 8, borderRadius: "50%", background: TONE_DOT[e.tone] }} />
<div className="flex-fill" style={{ minWidth: 0 }}>
<div className="text-break">
{e.title}
{e.link && (
<Link to={e.link} className="ms-2 small">
open
</Link>
)}
</div>
{e.detail && <div className="text-secondary small text-break">{e.detail}</div>}
<div className="text-secondary small">
{kinds.find((k) => k.id === e.kind)?.label ?? e.kind}
{e.actor ? ` · ${e.actor}` : ""}
</div>
</div>
</div>
</div>
))}
</div>
</div>
))}
{more && (
<div className="text-center mb-3">
<button className="btn" onClick={() => void older()} disabled={loadingMore}>
{loadingMore ? "Loading…" : "Show older"}
</button>
</div>
)}
</>
);
}
+53
View File
@@ -9,6 +9,7 @@ import {
api,
type CurrentUser,
type DomainList,
type EndpointCheck,
type IntegrationSummary,
type IntegrationType,
type OsTicketTicketsResponse,
@@ -362,9 +363,14 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
const [serverSummary, setServerSummary] = useState<ServerSummary | null>(null);
const [serverError, setServerError] = useState<string | null>(null);
const [domainList, setDomainList] = useState<DomainList | null>(null);
const [endpointChecks, setEndpointChecks] = useState<EndpointCheck[] | null>(null);
const [domainError, setDomainError] = useState<string | null>(null);
useEffect(() => {
api.endpoints
.list()
.then((res) => setEndpointChecks(res.checks))
.catch(() => setEndpointChecks([]));
api.domains
.list()
.then(setDomainList)
@@ -604,11 +610,16 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
{ id: "people", title: "Let someone else in (optional)", description: "Others sign in with Authentik and appear under Users; you decide their role.", to: "/users", action: "Open Users", done: (userCount ?? 0) > 1 },
];
// What the endpoint checks say: the ones that keep failing, and the certificates that are running out.
const endpointsDown = (endpointChecks ?? []).filter((c) => c.enabled && c.lastOk === false && c.consecutiveFailures >= c.failuresBeforeAlert);
const endpointCerts = (endpointChecks ?? []).filter((c) => c.enabled && c.certExpiresAt && Math.floor((Date.parse(c.certExpiresAt) - Date.now()) / 86_400_000) <= c.warnDays).length;
// What has nothing set up yet. These get one list at the bottom instead of a grey "Not configured" card each.
const notSetUp: { label: string; to: string; what: string }[] = [];
if (dnsStats?.totalProviders === 0) notSetUp.push({ label: "DNS", to: "/dns", what: "connect a DNS provider to see zones and records" });
if (secrets !== null && totalSecrets === 0) notSetUp.push({ label: "Secrets", to: "/secrets", what: "track when a token, certificate or password expires" });
if (serverSummary?.total === 0) notSetUp.push({ label: "Servers", to: "/servers", what: "add a server and install its agent" });
if (endpointChecks !== null && endpointChecks.length === 0) notSetUp.push({ label: "Endpoints", to: "/endpoints", what: "ask a web address, a port or a certificate whether it is fine" });
if (domainList !== null && domains.length === 0) notSetUp.push({ label: "Domains", to: "/domains", what: "appear after a DNS zone is added and the daily check has run" });
if (integrations !== null) {
for (const { type, label } of WIDGETS) {
@@ -931,6 +942,48 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
</>
)}
</WidgetCard>
<WidgetCard
label="Endpoints"
hide={endpointChecks !== null && endpointChecks.length === 0}
badge={
!endpointChecks ? undefined : endpointsDown.length > 0 ? (
<span className="badge bg-red-lt text-red">{endpointsDown.length} not answering</span>
) : endpointCerts > 0 ? (
<span className="badge bg-yellow-lt text-yellow">
{endpointCerts} certificate{endpointCerts === 1 ? "" : "s"} to renew
</span>
) : (
<span className="badge bg-green-lt text-green">All answering</span>
)
}
>
{!endpointChecks ? (
<WidgetSkeleton />
) : (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Checks" value={endpointChecks.filter((c) => c.enabled).length} />
</div>
<div className="col-4">
<MiniStat label="Up" value={endpointChecks.filter((c) => c.enabled && c.lastOk === true).length} />
</div>
<div className="col-4">
<MiniStat label="Down" value={endpointsDown.length} accent={endpointsDown.length > 0 ? "#ef4444" : undefined} />
</div>
</div>
{endpointsDown.slice(0, 3).map((c) => (
<div key={c.id} className="text-red small">
{c.name} — {c.lastMessage}
</div>
))}
<div className="text-secondary small mt-2">
<Link to="/endpoints">All checks</Link>
</div>
</>
)}
</WidgetCard>
</div>
<SectionHeader
+494
View File
@@ -0,0 +1,494 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type CurrentUser, type EndpointCheck, type EndpointInput, type EndpointKind } from "../api/client";
import Pagination from "../components/Pagination";
import SortableTh from "../components/SortableTh";
import TableToolbar from "../components/TableToolbar";
import TimeAgo from "../components/TimeAgo";
import { ErrorNotice } from "../components/Notice";
import { BlockSkeleton } from "../components/Skeleton";
import { usePagination } from "../hooks/usePagination";
import { useSortable } from "../hooks/useSortable";
import { useTableSearch } from "../hooks/useTableSearch";
import { downloadCsv } from "../utils/csv";
import { confirmDialog } from "../utils/dialogs";
import { readableError } from "../utils/errors";
import { toast } from "../utils/toast";
const KIND_LABELS: Record<EndpointKind, string> = { http: "Web address", tcp: "Port", tls: "Certificate" };
const KIND_HINTS: Record<EndpointKind, string> = {
http: "Asks the address and wants a good answer (and, if you like, a word in the page).",
tcp: "Opens a connection to the port and sees whether anything answers.",
tls: "Reads the certificate the service shows and warns before it runs out.",
};
type State = "waiting" | "up" | "failing" | "down" | "off";
const STATE_BADGE: Record<State, { label: string; badge: string }> = {
waiting: { label: "Not asked yet", badge: "bg-secondary-lt text-secondary" },
up: { label: "Up", badge: "bg-green-lt text-green" },
failing: { label: "Failing", badge: "bg-yellow-lt text-yellow" },
down: { label: "Down", badge: "bg-red-lt text-red" },
off: { label: "Switched off", badge: "bg-secondary-lt text-secondary" },
};
const RANK: Record<State, number> = { down: 0, failing: 1, waiting: 2, up: 3, off: 4 };
function stateOf(c: EndpointCheck): State {
if (!c.enabled) return "off";
if (c.lastOk === null) return "waiting";
if (c.lastOk) return "up";
return c.consecutiveFailures >= c.failuresBeforeAlert ? "down" : "failing";
}
const daysLeft = (iso: string | null) => (iso ? Math.floor((Date.parse(iso) - Date.now()) / 86_400_000) : null);
interface Row extends EndpointCheck {
state: State;
rank: number;
certDays: number | null;
uptime24h: number | null;
}
/** The last results as a row of small ticks: green for an answer, red for none. */
function Ticks({ recent }: { recent: { at: string; ok: boolean }[] }) {
if (recent.length === 0) return <span className="text-secondary">—</span>;
return (
<span className="d-inline-flex gap-1 align-middle" role="img" aria-label={`The last ${recent.length} checks: ${recent.filter((r) => r.ok).length} answered`}>
{recent.map((r) => (
<span key={r.at} title={`${r.at.slice(0, 16).replace("T", " ")} UTC — ${r.ok ? "answered" : "no good answer"}`} style={{ width: 4, height: 14, borderRadius: 1, background: r.ok ? "#2fb344" : "#e05252", display: "inline-block" }} />
))}
</span>
);
}
interface Draft {
id: number | null;
name: string;
kind: EndpointKind;
target: string;
port: string;
expectStatus: string;
keyword: string;
insecure: boolean;
intervalMinutes: string;
timeoutSeconds: string;
failuresBeforeAlert: string;
warnDays: string;
serverId: string;
enabled: boolean;
}
const EMPTY: Draft = { id: null, name: "", kind: "http", target: "", port: "", expectStatus: "", keyword: "", insecure: false, intervalMinutes: "5", timeoutSeconds: "10", failuresBeforeAlert: "2", warnDays: "14", serverId: "", enabled: true };
const toDraft = (c: EndpointCheck): Draft => ({
id: c.id,
name: c.name,
kind: c.kind,
target: c.target,
port: c.port === null ? "" : String(c.port),
expectStatus: c.expectStatus ?? "",
keyword: c.keyword ?? "",
insecure: c.insecure,
intervalMinutes: String(c.intervalMinutes),
timeoutSeconds: String(c.timeoutSeconds),
failuresBeforeAlert: String(c.failuresBeforeAlert),
warnDays: String(c.warnDays),
serverId: c.serverId === null ? "" : String(c.serverId),
enabled: c.enabled,
});
const toInput = (d: Draft): EndpointInput => ({
name: d.name.trim(),
kind: d.kind,
target: d.target.trim(),
port: d.kind === "http" || d.port.trim() === "" ? null : Number(d.port),
expectStatus: d.kind === "http" && d.expectStatus.trim() ? d.expectStatus.trim() : null,
keyword: d.kind === "http" && d.keyword ? d.keyword : null,
insecure: d.insecure,
intervalMinutes: Number(d.intervalMinutes),
timeoutSeconds: Number(d.timeoutSeconds),
failuresBeforeAlert: Number(d.failuresBeforeAlert),
warnDays: Number(d.warnDays),
serverId: d.serverId === "" ? null : Number(d.serverId),
enabled: d.enabled,
});
/**
* "Is it up?" for the simple cases: a web address, a TCP port, a certificate. The app asks every few minutes, remembers how it went, and
* raises an alert (and a notification) when a check keeps failing or a certificate is about to run out. Everyone can look; an administrator
* sets them up, since each one makes this server connect somewhere.
*/
export default function Endpoints({ user }: { user: CurrentUser }) {
const isAdmin = user.role === "admin";
const canCheck = user.role === "admin" || user.role === "operator";
const [checks, setChecks] = useState<EndpointCheck[] | null>(null);
const [servers, setServers] = useState<{ id: number; name: string }[]>([]);
const [error, setError] = useState<string | null>(null);
const [draft, setDraft] = useState<Draft | null>(null);
const [busy, setBusy] = useState(false);
const [asking, setAsking] = useState<number | null>(null);
function load() {
api.endpoints
.list()
.then((res) => {
setChecks(res.checks);
setServers(res.servers);
})
.catch((err) => setError(readableError(err)));
}
useEffect(() => {
load();
// The results come in on their own every few minutes: look again now and then.
const t = setInterval(load, 60_000);
return () => clearInterval(t);
}, []);
const rows: Row[] = (checks ?? []).map((c) => ({ ...c, state: stateOf(c), rank: RANK[stateOf(c)], certDays: daysLeft(c.certExpiresAt), uptime24h: c.stats?.uptime24h ?? null }));
const tableSearch = useTableSearch(rows);
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered, "rank", "asc", { url: true });
const page = usePagination(sorted);
const down = rows.filter((r) => r.state === "down" || r.state === "failing").length;
const certs = rows.filter((r) => r.certDays !== null && r.certDays <= r.warnDays).length;
async function save(e: React.FormEvent) {
e.preventDefault();
if (!draft) return;
setBusy(true);
setError(null);
try {
if (draft.id === null) await api.endpoints.create(toInput(draft));
else await api.endpoints.update(draft.id, toInput(draft));
toast.success(draft.id === null ? `Added ${draft.name}.` : "Saved.");
setDraft(null);
load();
} catch (err) {
setError(readableError(err));
} finally {
setBusy(false);
}
}
async function remove(c: EndpointCheck) {
if (!(await confirmDialog({ title: "Remove a check", message: `Remove "${c.name}" and its history?`, confirmLabel: "Remove", danger: true }))) return;
try {
await api.endpoints.remove(c.id);
load();
} catch (err) {
setError(readableError(err));
}
}
async function askNow(c: EndpointCheck) {
setAsking(c.id);
try {
const { result } = await api.endpoints.check(c.id);
if (result.ok) toast.success(`${c.name}: ${result.message}`);
else toast.error(`${c.name}: ${result.message}`);
load();
} catch (err) {
setError(readableError(err));
} finally {
setAsking(null);
}
}
function exportCsv() {
downloadCsv(
"endpoint-checks.csv",
["Name", "Kind", "Target", "Port", "Status", "Last answer", "Answer time (ms)", "Uptime 24 h (%)", "Uptime 7 d (%)", "Certificate expires", "Last checked", "Server"],
(sorted ?? []).map((r) => [r.name, KIND_LABELS[r.kind], r.target, r.port ?? "", STATE_BADGE[r.state].label, r.lastMessage ?? "", r.lastResponseMs ?? "", r.stats?.uptime24h ?? "", r.stats?.uptime7d ?? "", r.certExpiresAt?.slice(0, 10) ?? "", r.lastCheckedAt ?? "", r.server?.name ?? ""]),
);
}
const set = <K extends keyof Draft>(key: K, value: Draft[K]) => setDraft((d) => (d ? { ...d, [key]: value } : d));
const cards = [
{ label: "Checks", value: checks ? String(rows.length) : "…", color: "" },
{ label: "Not answering", value: checks ? String(down) : "…", color: down > 0 ? "text-red" : "text-green" },
{ label: "Certificates to renew", value: checks ? String(certs) : "…", color: certs > 0 ? "text-yellow" : "" },
];
return (
<>
<div className="d-flex align-items-center mb-1">
<h2 className="page-title mb-0">Endpoints</h2>
{isAdmin && !draft && (
<button className="btn btn-primary ms-auto" onClick={() => setDraft({ ...EMPTY })}>
Add a check
</button>
)}
</div>
<p className="text-secondary">
The app asks a web address, a port or a certificate whether it is fine, every few minutes, and says so on the <Link to="/alerts">Alerts</Link> page and in notifications when it keeps failing or a
certificate is about to run out.
</p>
<ErrorNotice error={error} />
<div className="row row-cards mb-3">
{cards.map((c) => (
<div className="col-6 col-md-4" 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>
</div>
</div>
</div>
))}
</div>
{draft && (
<form className="card mb-3" onSubmit={save}>
<div className="card-header">
<h3 className="card-title">{draft.id === null ? "Add a check" : `Edit ${draft.name || "the check"}`}</h3>
</div>
<div className="card-body row g-3">
<div className="col-md-4">
<label className="form-label" htmlFor="ep-name">
Name
</label>
<input id="ep-name" className="form-control" required maxLength={100} placeholder="e.g. Gitea" value={draft.name} onChange={(e) => set("name", e.target.value)} />
</div>
<div className="col-md-4">
<label className="form-label" htmlFor="ep-kind">
What to ask
</label>
<select id="ep-kind" className="form-select" value={draft.kind} onChange={(e) => set("kind", e.target.value as EndpointKind)}>
{(Object.keys(KIND_LABELS) as EndpointKind[]).map((k) => (
<option key={k} value={k}>
{KIND_LABELS[k]}
</option>
))}
</select>
<div className="form-hint text-secondary small mt-1">{KIND_HINTS[draft.kind]}</div>
</div>
<div className="col-md-4">
<label className="form-label" htmlFor="ep-server">
It is about the server
</label>
<select id="ep-server" className="form-select" value={draft.serverId} onChange={(e) => set("serverId", e.target.value)}>
<option value="">— none in particular —</option>
{servers.map((s) => (
<option key={s.id} value={s.id}>
{s.name}
</option>
))}
</select>
<div className="form-hint text-secondary small mt-1">Maintenance on that server silences this check&rsquo;s alerts, and its tags can route them.</div>
</div>
<div className={draft.kind === "http" ? "col-md-8" : "col-md-5"}>
<label className="form-label" htmlFor="ep-target">
{draft.kind === "http" ? "Address" : "Host name or address"}
</label>
<input
id="ep-target"
className="form-control"
required
maxLength={500}
placeholder={draft.kind === "http" ? "https://git.example.lan/" : "git.example.lan"}
value={draft.target}
onChange={(e) => set("target", e.target.value)}
/>
</div>
{draft.kind !== "http" && (
<div className="col-md-3">
<label className="form-label" htmlFor="ep-port">
Port
</label>
<input id="ep-port" type="number" min={1} max={65535} className="form-control" required value={draft.port} placeholder={draft.kind === "tls" ? "443" : ""} onChange={(e) => set("port", e.target.value)} />
</div>
)}
{draft.kind === "http" && (
<>
<div className="col-md-2">
<label className="form-label" htmlFor="ep-status">
Good answers
</label>
<input id="ep-status" className="form-control" placeholder="200-399" value={draft.expectStatus} onChange={(e) => set("expectStatus", e.target.value)} />
</div>
<div className="col-md-2">
<label className="form-label" htmlFor="ep-keyword">
Page contains
</label>
<input id="ep-keyword" className="form-control" maxLength={200} value={draft.keyword} onChange={(e) => set("keyword", e.target.value)} />
</div>
</>
)}
<div className="col-md-2">
<label className="form-label" htmlFor="ep-interval">
Every
</label>
<div className="input-group">
<input id="ep-interval" type="number" min={1} max={1440} className="form-control" value={draft.intervalMinutes} onChange={(e) => set("intervalMinutes", e.target.value)} />
<span className="input-group-text">min</span>
</div>
</div>
<div className="col-md-2">
<label className="form-label" htmlFor="ep-timeout">
Give up after
</label>
<div className="input-group">
<input id="ep-timeout" type="number" min={1} max={60} className="form-control" value={draft.timeoutSeconds} onChange={(e) => set("timeoutSeconds", e.target.value)} />
<span className="input-group-text">s</span>
</div>
</div>
<div className="col-md-3">
<label className="form-label" htmlFor="ep-fails">
Alert after
</label>
<div className="input-group">
<input id="ep-fails" type="number" min={1} max={20} className="form-control" value={draft.failuresBeforeAlert} onChange={(e) => set("failuresBeforeAlert", e.target.value)} />
<span className="input-group-text">failures in a row</span>
</div>
</div>
<div className="col-md-3">
<label className="form-label" htmlFor="ep-warn">
Warn about the certificate
</label>
<div className="input-group">
<input id="ep-warn" type="number" min={1} max={90} className="form-control" value={draft.warnDays} onChange={(e) => set("warnDays", e.target.value)} />
<span className="input-group-text">days before</span>
</div>
</div>
<div className="col-12 d-flex flex-wrap gap-4">
<label className="form-check mb-0">
<input type="checkbox" className="form-check-input" checked={draft.insecure} onChange={(e) => set("insecure", e.target.checked)} />
<span className="form-check-label">Accept a certificate that isn&rsquo;t trusted (self-signed, a private authority). Its expiry is still watched.</span>
</label>
<label className="form-check mb-0">
<input type="checkbox" className="form-check-input" checked={draft.enabled} onChange={(e) => set("enabled", e.target.checked)} />
<span className="form-check-label">Switched on</span>
</label>
</div>
<div className="col-12 text-secondary small">Only addresses this server may reach are accepted: not itself (loopback) and not the cloud metadata address. Your own network is fine.</div>
</div>
<div className="card-footer d-flex gap-2">
<button type="submit" className="btn btn-primary" disabled={busy || draft.name.trim() === "" || draft.target.trim() === ""}>
{busy ? "Saving…" : "Save"}
</button>
<button type="button" className="btn" onClick={() => setDraft(null)}>
Cancel
</button>
</div>
</form>
)}
<div className="card">
<TableToolbar search={tableSearch.query} onSearch={tableSearch.setQuery} placeholder="Search checks…" shown={sorted?.length} total={rows.length} onExport={exportCsv} exportDisabled={!sorted || sorted.length === 0} />
<div className="table-responsive">
<table className="table table-vcenter card-table table-stack">
<thead>
<tr>
<SortableTh<Row> label="Check" sortKeyName="name" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Status" sortKeyName="rank" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Answer" sortKeyName="lastResponseMs" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Uptime" sortKeyName="uptime24h" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Certificate" sortKeyName="certDays" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Checked" sortKeyName="lastCheckedAt" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
{(canCheck || isAdmin) && <th className="w-1">Actions</th>}
</tr>
</thead>
<tbody>
{checks === null && !error && (
<tr>
<td colSpan={7}>
<BlockSkeleton lines={3} />
</td>
</tr>
)}
{page.pageItems?.map((c) => (
<tr key={c.id}>
<td className="stack-wide">
<strong>{c.name}</strong> <span className="badge bg-secondary-lt text-secondary">{KIND_LABELS[c.kind]}</span>
<div className="text-secondary small text-break">
{c.target}
{c.port !== null ? `:${c.port}` : ""}
</div>
{c.server && (
<div className="small">
about <Link to={`/servers/${c.server.id}`}>{c.server.name}</Link>
</div>
)}
</td>
<td>
<span className={`badge ${STATE_BADGE[c.state].badge}`}>{STATE_BADGE[c.state].label}</span>
{c.lastOk === false && c.lastMessage && <div className="text-secondary small">{c.lastMessage}</div>}
{c.lastOk === false && c.state === "failing" && (
<div className="text-secondary small">
failed {c.consecutiveFailures} of {c.failuresBeforeAlert}
</div>
)}
</td>
<td className="stack-label" data-label="Answer">
{c.lastResponseMs === null ? <span className="text-secondary">—</span> : `${c.lastResponseMs} ms`}
{c.stats?.avgMs24h != null && <div className="text-secondary small">avg {c.stats.avgMs24h} ms</div>}
</td>
<td className="stack-label" data-label="Uptime">
{c.stats?.uptime24h == null ? (
<span className="text-secondary">—</span>
) : (
<>
{c.stats.uptime24h}% <span className="text-secondary small">24 h</span>
<div className="text-secondary small">{c.stats.uptime7d}% 7 d</div>
</>
)}
<div>
<Ticks recent={c.stats?.recent ?? []} />
</div>
</td>
<td className="stack-label" data-label="Certificate">
{c.certDays === null ? (
<span className="text-secondary">—</span>
) : c.certDays < 0 ? (
<span className="badge bg-red-lt text-red" title={c.certExpiresAt?.slice(0, 10)}>
expired {-c.certDays} d ago
</span>
) : c.certDays <= c.warnDays ? (
<span className={`badge ${c.certDays <= 3 ? "bg-red-lt text-red" : "bg-yellow-lt text-yellow"}`} title={c.certExpiresAt?.slice(0, 10)}>
{c.certDays} d left
</span>
) : (
<span className="text-secondary">{c.certDays} d left</span>
)}
</td>
<td className="text-secondary stack-label" data-label="Checked">
{c.lastCheckedAt ? <TimeAgo value={c.lastCheckedAt} /> : "—"}
</td>
{(canCheck || isAdmin) && (
<td className="stack-wide">
<div className="btn-list flex-nowrap">
{canCheck && (
<button className="btn btn-sm btn-outline-primary" disabled={asking === c.id} onClick={() => void askNow(c)}>
{asking === c.id ? "Asking…" : "Check now"}
</button>
)}
{isAdmin && (
<>
<button className="btn btn-sm btn-outline-secondary" onClick={() => setDraft(toDraft(c))}>
Edit
</button>
<button className="btn btn-sm btn-outline-danger" onClick={() => void remove(c)}>
Remove
</button>
</>
)}
</div>
</td>
)}
</tr>
))}
{checks !== null && sorted?.length === 0 && (
<tr>
<td colSpan={7} className="text-secondary text-center">
{tableSearch.active ? "Nothing matches that." : `Nothing is being checked yet.${isAdmin ? " Add the first check: a web address, a port, or a certificate." : ""}`}
</td>
</tr>
)}
</tbody>
</table>
</div>
<Pagination page={page.page} pageCount={page.pageCount} totalCount={page.totalCount} onPageChange={page.setPage} />
</div>
</>
);
}
@@ -81,7 +81,7 @@ const DIGEST_DAYS: { value: number; label: string }[] = [
{ value: 6, label: "Saturday" },
{ value: 0, label: "Sunday" },
];
const DEFAULT_HEALTH_CHECKS: HealthCheckSettings = { serverOfflineMinutes: 60, diskUsagePercent: 90, domainWarnDays: 30, diskForecastDays: 14, backupStaleHours: 48 };
const DEFAULT_HEALTH_CHECKS: HealthCheckSettings = { serverOfflineMinutes: 60, diskUsagePercent: 90, domainWarnDays: 30, diskForecastDays: 14, backupStaleHours: 48, restoreTestDays: 0 };
type TestResult = { ok: boolean; message: string } | null;
type EventKey = { [K in keyof NotificationEvents]: NotificationEvents[K] extends boolean ? K : never }[keyof NotificationEvents];
@@ -745,6 +745,15 @@ export default function NotificationSettings() {
hint="Shown on the Alerts page for every guest whose newest backup (on Proxmox or a Backup Server) is older than this, and sent once a day with the other backup messages. A server can have its own limit. 0 turns it off."
onChange={(v) => setHealthChecks((h) => ({ ...h, backupStaleHours: v }))}
/>
<NumberField
label="A restore should have been tested within"
value={healthChecks.restoreTestDays}
min={0}
max={730}
unit="days"
hint="On the Alerts page, for every guest that has backups but no restore test recorded on the Backups page (or none that recent). A test that failed is always raised, whatever this says. 0 turns the reminder off."
onChange={(v) => setHealthChecks((h) => ({ ...h, restoreTestDays: v }))}
/>
{toggle("pbsVerificationCheck", "Proxmox Backup Server snapshot failed verification")}
{toggle("dockerUpdateCheck", "Docker image update available")}
</div>