Mirror Uptime Kuma's maintenance schedule as maintenance windows

Uptime Kuma shares its maintenance windows only over its dashboard Socket.IO
connection, which takes a login. With a login username and password on the
integration, "Sync schedule" on the Maintenance page (and a 15-minute
background pass when switched on) reads each window's running and next time
slot and the monitors it covers, and makes a maintenance window on every
server those monitors match. Windows that haven't started are listed as
Scheduled and silence nothing until they begin; ones ended or cancelled by
hand stay ended, and ones removed in Kuma are removed here.

maintenance_windows gets a source column (migration 0017) and active windows
now require their start to have passed. Adds socket.io-client, and tests
against a stand-in Uptime Kuma speaking the same protocol.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-11 23:43:47 +02:00
1 parent 5e416b0273
commit 9e483f2163
21 files changed
+3259 -31

No files matched your search

+21 -1
View File
@@ -42,6 +42,8 @@ export interface MaintenanceWindow {
startedAt: string;
endsAt: string;
createdBy: string | null;
/** Set on windows mirrored from Uptime Kuma's schedule ("kuma:<integration>:<maintenance>"); null for ones started by hand. */
source: string | null;
}
export interface MaintenanceTargets {
@@ -773,6 +775,22 @@ export interface UptimeKumaMonitorsResponse {
summary: { total: number; up: number; down: number; pending: number; maintenance: number; unknown: number };
}
export interface UptimeKumaSyncResult {
maintenances: {
id: number;
title: string;
strategy: string;
status: string;
servers: string[];
unmatched: string[];
/** Why it produced no window, when it did not. */
note: string | null;
}[];
started: number;
updated: number;
removed: number;
}
export interface UptimeKumaImportResult {
imported: { serverId: number; serverName: string; monitorName: string; extended: boolean }[];
unmatched: string[];
@@ -1043,10 +1061,12 @@ export const api = {
}),
},
maintenance: {
list: () => request<{ windows: MaintenanceWindow[]; targets: MaintenanceTargets }>("/api/maintenance"),
list: () => request<{ windows: MaintenanceWindow[]; upcoming: MaintenanceWindow[]; targets: MaintenanceTargets }>("/api/maintenance"),
start: (data: { targetType: MaintenanceTargetType; targetId: number; minutes: number; reason?: string }) =>
request<{ window: MaintenanceWindow }>("/api/maintenance", { method: "POST", body: JSON.stringify(data) }),
end: (id: number) => request<void>(`/api/maintenance/${id}`, { method: "DELETE" }),
syncUptimeKuma: (data: { integrationId: number }) =>
request<UptimeKumaSyncResult>("/api/maintenance/sync/uptimekuma", { method: "POST", body: JSON.stringify(data) }),
importUptimeKuma: (data: { integrationId: number; minutes: number }) =>
request<UptimeKumaImportResult>("/api/maintenance/import/uptimekuma", { method: "POST", body: JSON.stringify(data) }),
},