diff --git a/build_nid_viewer.py b/build_nid_viewer.py index 3e00a89..7393862 100644 --- a/build_nid_viewer.py +++ b/build_nid_viewer.py @@ -734,6 +734,9 @@ function formatUptime(sec) {{ p.push(s+'s'); return p.join(' '); }} +// SNMP TruthValue: some agents return '1'/'2', others 'true'/'false' +function isTrue(v) {{ return v === '1' || v === 'true' || v === true; }} + // Derive data ports and management port from connectors dynamically function getPortLists() {{ const connectors = DATA.connectors || {{}}; @@ -990,7 +993,7 @@ function renderHeader() {{ const cfgByNum = {{}}; for (const [k,v] of Object.entries(alarmCfg)) cfgByNum[v.number] = v; for (const [k,a] of Object.entries(alarmStatus)) {{ - if (a.active === '1') {{ + if (isTrue(a.active)) {{ activeCount++; const cfg = cfgByNum[a.number]; if (cfg) sevCounts[cfg.severity] = (sevCounts[cfg.severity]||0) + 1; @@ -1137,7 +1140,7 @@ function renderPanel() {{ const iface = ifaces[connIdx]; if (connType(connIdx) === 'sfp') {{ const sfp = sfpInfo[connIdx]; - const present = sfp && sfp.present === '1'; + const present = sfp && isTrue(sfp.present); if (!present) return 'empty'; if (iface && isUp(iface.ifOperStatus)) return 'present-link'; return 'present-nolink'; @@ -1152,7 +1155,7 @@ function renderPanel() {{ function sfpLabel(connIdx) {{ const sfp = sfpInfo[connIdx]; if (!sfp) return ''; - if (sfp.present !== '1') return 'EMPTY'; + if (!isTrue(sfp.present)) return 'EMPTY'; const pn = sfp.vendorPn || ''; if (pn.length > 8) return pn.substring(0,8); return pn || sfp.vendor || ''; @@ -1214,7 +1217,7 @@ function renderPanel() {{ // Power feeds let pwrHtml = '