fix(checkmk): add diagnostic log to compare config vs monitoring host IDs

This commit is contained in:
Brückner
2026-06-04 14:57:19 +02:00
parent a58b321a50
commit 789fe1f8e0

View File

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