From 789fe1f8e049cc14f3e0ebf6e350614b2609dc27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Br=C3=BCckner?= Date: Thu, 4 Jun 2026 14:57:19 +0200 Subject: [PATCH] fix(checkmk): add diagnostic log to compare config vs monitoring host IDs --- server.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server.ts b/server.ts index 571659a..95102a2 100644 --- a/server.ts +++ b/server.ts @@ -757,6 +757,13 @@ async function startServer() { const state: number | undefined = host?.extensions?.state; if (name !== undefined && state !== undefined) hostnameToState.set(name, state); } + + // Diagnostic: log a sample so mismatches between config and monitoring IDs are visible + const cfgSample = [...ipToHostname.values()].slice(0, 3).join(', '); + const monSample = [...hostnameToState.keys()].slice(0, 3).join(', '); + db.prepare('INSERT INTO logs (id, timestamp, type, message) VALUES (?, ?, ?, ?)') + .run(uid('log'), now, 'system', + `CheckMK diagnostic — config hosts (${ipToHostname.size}): [${cfgSample}] | monitoring hosts (${hostnameToState.size}): [${monSample}]`); } catch (err: any) { const msg = `CheckMK sync failed — could not fetch monitoring states: ${err?.message ?? err}`; console.error('[CheckMK]', msg);