// src/services/voiceDiag/checks/port/portEnabled.js // // Store phone standard: administratively enabled on every wired- // phone switchport. If the port is admin-disabled the phone // obviously won't work — this is a common footgun when a tech // disables the wrong port during troubleshooting. // // Env kill-switch (shared with the other port checks) — // VOICE_STANDARD_ENABLED=false → check reports skipped // so operators can silence all port-hygiene noise while the // underlying Meraki state is being cleaned up. // // Skip rules: // - Wireless: skipped. // - Trunk uplink: skipped (owned by portType check). // - No portEnabled field at all: reported as unknown. import { collectPortDevices, isWireless, portLabelFor, maybeSkippedByKillSwitch } from './_helpers.js'; export const PORT_ENABLED_STANDARDS = Object.freeze({ portEnabled: true, }); export const portEnabledCheck = { id: 'portEnabled', label: 'Switchport Admin State', requires: ['phoneStatus'], scope: null, standards: PORT_ENABLED_STANDARDS, async run(ctx) { const skip = maybeSkippedByKillSwitch(portEnabledCheck); if (skip) return skip; const devices = collectPortDevices(ctx.phoneStatus); if (devices.length === 0) { return { status: 'skipped', message: 'No wired devices with Meraki port data to inspect.', details: null, remediation: null, }; } const perDevice = devices.map((d) => { if (isWireless(d)) { return { ...portLabelFor(d), portEnabled: null, verdict: 'wireless' }; } const portType = d.meraki?.portType; if (portType && String(portType).toLowerCase() === 'trunk') { return { ...portLabelFor(d), portEnabled: null, verdict: 'trunk-skip' }; } const enabled = d.meraki?.portEnabled; if (enabled === undefined || enabled === null) { return { ...portLabelFor(d), portEnabled: null, verdict: 'unknown' }; } return { ...portLabelFor(d), portEnabled: !!enabled, verdict: enabled ? 'compliant' : 'disabled' }; }); const disabled = perDevice.filter((r) => r.verdict === 'disabled'); const unknown = perDevice.filter((r) => r.verdict === 'unknown'); const details = { total: perDevice.length, compliant: perDevice.filter((r) => r.verdict === 'compliant').length, disabled: disabled.length, unknown: unknown.length, wireless: perDevice.filter((r) => r.verdict === 'wireless').length, trunkSkipped: perDevice.filter((r) => r.verdict === 'trunk-skip').length, offenders: disabled, }; if (disabled.length > 0) { return { status: 'error', message: `${disabled.length} device(s) on ADMIN-DISABLED switchports (phone will not work): ` + disabled.map((r) => `${r.deviceLabel}@${r.portLabel}`).join(', '), details, remediation: null, }; } if (unknown.length > 0) { return { status: 'warn', message: `${unknown.length} device(s) have no admin-state info from Meraki.`, details, remediation: null, }; } return { status: 'ok', message: `All ${details.compliant} wired switchports admin-enabled.`, details, remediation: null, }; }, };