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:
1 parent
b5384c1e03
commit
c3bc6bbf72
26 files changed
+4118
-45
No files matched your search
@@ -21,6 +21,8 @@ export interface ServerThresholds {
|
||||
/** 0 turns the stale-backup alert off for this server's guest. */
|
||||
backupStaleHours?: number;
|
||||
mounts?: Record<string, MountThreshold>;
|
||||
/** Services (units) never to count as failed on this server: names or patterns like "gupdate*" (case does not matter, ".service" is optional). */
|
||||
ignoreServices?: string[];
|
||||
}
|
||||
|
||||
/** The global values these override. */
|
||||
@@ -38,6 +40,8 @@ export const LIMITS = {
|
||||
backupStaleHours: { min: 0, max: 2160 },
|
||||
} as const;
|
||||
export const MAX_MOUNT_RULES = 50;
|
||||
export const MAX_IGNORED_SERVICES = 30;
|
||||
const MAX_SERVICE_PATTERN = 100;
|
||||
|
||||
const inRange = (v: unknown, key: keyof typeof LIMITS): v is number => typeof v === "number" && Number.isInteger(v) && v >= LIMITS[key].min && v <= LIMITS[key].max;
|
||||
|
||||
@@ -61,6 +65,11 @@ export function parseThresholds(stored: string | null | undefined): ServerThresh
|
||||
}
|
||||
if (Object.keys(mounts).length > 0) out.mounts = mounts;
|
||||
}
|
||||
if (Array.isArray(v.ignoreServices)) {
|
||||
const strings: string[] = (v.ignoreServices as unknown[]).filter((p): p is string => typeof p === "string");
|
||||
const list = [...new Set(strings.map((p) => p.trim()).filter((p) => p.length > 0 && p.length <= MAX_SERVICE_PATTERN))].slice(0, MAX_IGNORED_SERVICES);
|
||||
if (list.length > 0) out.ignoreServices = list;
|
||||
}
|
||||
return Object.keys(out).length > 0 ? out : null;
|
||||
} catch {
|
||||
return null;
|
||||
@@ -103,6 +112,20 @@ export function checkThresholds(input: unknown): { ok: true; value: ServerThresh
|
||||
}
|
||||
if (Object.keys(mounts).length > 0) out.mounts = mounts;
|
||||
}
|
||||
if (v.ignoreServices !== undefined && v.ignoreServices !== null) {
|
||||
if (!Array.isArray(v.ignoreServices)) return { ok: false, message: "The services to ignore should be a list." };
|
||||
const list: string[] = [];
|
||||
for (const raw of v.ignoreServices) {
|
||||
if (typeof raw !== "string") return { ok: false, message: "Each service to ignore should be a name or a pattern." };
|
||||
const p = raw.trim();
|
||||
if (p.length === 0) continue;
|
||||
// eslint-disable-next-line no-control-regex
|
||||
if (p.length > MAX_SERVICE_PATTERN || /[\u0000-\u001f]/.test(p)) return { ok: false, message: `"${p.slice(0, 30)}…" isn't a service name or pattern (up to ${MAX_SERVICE_PATTERN} characters, no line breaks).` };
|
||||
if (!list.includes(p)) list.push(p);
|
||||
}
|
||||
if (list.length > MAX_IGNORED_SERVICES) return { ok: false, message: `At most ${MAX_IGNORED_SERVICES} services can be ignored on one server.` };
|
||||
if (list.length > 0) out.ignoreServices = list;
|
||||
}
|
||||
return { ok: true, value: Object.keys(out).length > 0 ? out : null };
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user