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);