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

+62
View File
@@ -127,6 +127,68 @@ export const pushSubscriptions = sqliteTable("push_subscriptions", {
categories: text("categories"),
});
// A web address, TCP port or TLS certificate the app asks about every few minutes — see services/endpointChecks.ts. The last answer is kept on the row;
// every answer is also one row in endpoint_results (kept two weeks), for uptime and answer times.
export const endpointChecks = sqliteTable("endpoint_checks", {
id: integer("id").primaryKey({ autoIncrement: true }),
name: text("name").notNull(),
kind: text("kind").notNull(), // http | tcp | tls
target: text("target").notNull(), // http: the web address; tcp and tls: the host
port: integer("port"), // tcp and tls
expectStatus: text("expect_status"), // http: "200-299, 301"; null = 200-399
keyword: text("keyword"), // http: text the page must contain
insecure: integer("insecure", { mode: "boolean" }).notNull().default(false), // accept a certificate that isn't trusted (self-signed, a private CA)
intervalMinutes: integer("interval_minutes").notNull().default(5),
timeoutSeconds: integer("timeout_seconds").notNull().default(10),
failuresBeforeAlert: integer("failures_before_alert").notNull().default(2),
warnDays: integer("warn_days").notNull().default(14), // warn this long before a certificate expires
serverId: integer("server_id"), // soft reference: the server this is about, so its maintenance silences the alerts
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
lastCheckedAt: text("last_checked_at"),
lastOk: integer("last_ok", { mode: "boolean" }),
lastMessage: text("last_message"),
lastResponseMs: integer("last_response_ms"),
certExpiresAt: text("cert_expires_at"), // ISO
consecutiveFailures: integer("consecutive_failures").notNull().default(0),
lastChangeAt: text("last_change_at"), // when it last went from working to failing or back
createdAt: text("created_at")
.notNull()
.default(sql`(current_timestamp)`),
});
export const endpointResults = sqliteTable(
"endpoint_results",
{
id: integer("id").primaryKey({ autoIncrement: true }),
checkId: integer("check_id")
.notNull()
.references(() => endpointChecks.id, { onDelete: "cascade" }),
at: text("at").notNull(), // ISO
ok: integer("ok", { mode: "boolean" }).notNull(),
ms: integer("ms"),
message: text("message"),
},
(t) => [index("endpoint_results_check_idx").on(t.checkId, t.at)],
);
// One time somebody tried to restore a backup, and how it went — see services/restoreTests.ts. History is kept; the newest per subject is what counts.
export const restoreTests = sqliteTable(
"restore_tests",
{
id: integer("id").primaryKey({ autoIncrement: true }),
subjectKey: text("subject_key").notNull(), // guest:<integration id>:<vmid> for a Proxmox guest, custom:<slug> for anything else
label: text("label").notNull(),
testedAt: text("tested_at").notNull(), // YYYY-MM-DD
result: text("result").notNull(), // ok | partial | failed | not_needed
note: text("note"),
testedBy: text("tested_by"),
createdAt: text("created_at")
.notNull()
.default(sql`(current_timestamp)`),
},
(t) => [index("restore_tests_subject_idx").on(t.subjectKey, t.testedAt)],
);
// "A needs B", for things that can be down: a server or an integration each. Polymorphic like maintenance_windows (no foreign key); an edge whose
// end was deleted is ignored. When B is down, A's alert is folded under B's — see services/dependencies.ts.
export const dependencies = sqliteTable(