Add link speed and utilization tracking to interface stats
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -127,7 +127,8 @@
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-size: 9px;
|
||||
background: #555;
|
||||
font-weight: normal;
|
||||
background: #444;
|
||||
color: #fff;
|
||||
padding: 1px 6px;
|
||||
border-radius: 8px;
|
||||
@@ -167,7 +168,8 @@
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-size: 9px;
|
||||
background: #555;
|
||||
font-weight: normal;
|
||||
background: #444;
|
||||
color: #fff;
|
||||
padding: 1px 6px;
|
||||
border-radius: 8px;
|
||||
@@ -180,7 +182,8 @@
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-size: 9px;
|
||||
background: #864;
|
||||
font-weight: normal;
|
||||
background: #753;
|
||||
color: #fff;
|
||||
padding: 1px 6px;
|
||||
border-radius: 8px;
|
||||
@@ -189,22 +192,22 @@
|
||||
|
||||
.node .switch-port.speed-10g,
|
||||
.node .uplink.speed-10g {
|
||||
background: #468;
|
||||
background: #357;
|
||||
}
|
||||
|
||||
.node .switch-port.speed-1g,
|
||||
.node .uplink.speed-1g {
|
||||
background: #486;
|
||||
background: #375;
|
||||
}
|
||||
|
||||
.node .switch-port.speed-100m,
|
||||
.node .uplink.speed-100m {
|
||||
background: #864;
|
||||
background: #753;
|
||||
}
|
||||
|
||||
.node .switch-port.speed-slow,
|
||||
.node .uplink.speed-slow {
|
||||
background: #844;
|
||||
background: #733;
|
||||
}
|
||||
|
||||
.node:hover {
|
||||
@@ -304,6 +307,7 @@
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-size: 9px;
|
||||
font-weight: normal;
|
||||
padding: 1px 6px;
|
||||
border-radius: 8px;
|
||||
white-space: nowrap;
|
||||
@@ -327,12 +331,12 @@
|
||||
}
|
||||
|
||||
.node .dante-info.tx-info {
|
||||
background: #864;
|
||||
background: #753;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.node .dante-info.rx-info {
|
||||
background: #468;
|
||||
background: #357;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
@@ -828,17 +832,19 @@
|
||||
};
|
||||
}
|
||||
|
||||
function formatRate(bps) {
|
||||
if (bps < 1024) return bps.toFixed(0) + ' B/s';
|
||||
if (bps < 1024 * 1024) return (bps / 1024).toFixed(1) + ' KB/s';
|
||||
if (bps < 1024 * 1024 * 1024) return (bps / (1024 * 1024)).toFixed(1) + ' MB/s';
|
||||
return (bps / (1024 * 1024 * 1024)).toFixed(1) + ' GB/s';
|
||||
function formatMbps(bytesPerSec) {
|
||||
const mbps = (bytesPerSec * 8) / 1000000;
|
||||
return Math.round(mbps).toLocaleString() + ' Mbit/s';
|
||||
}
|
||||
|
||||
function formatPps(pps) {
|
||||
if (pps < 1000) return pps.toFixed(0) + ' pps';
|
||||
if (pps < 1000000) return (pps / 1000).toFixed(1) + 'K pps';
|
||||
return (pps / 1000000).toFixed(1) + 'M pps';
|
||||
return Math.round(pps).toLocaleString() + ' pps';
|
||||
}
|
||||
|
||||
function formatLinkSpeed(bps) {
|
||||
if (!bps) return '?';
|
||||
const mbps = bps / 1000000;
|
||||
return mbps.toLocaleString() + ' Mbit/s';
|
||||
}
|
||||
|
||||
let anonCounter = 0;
|
||||
@@ -940,11 +946,12 @@
|
||||
const errOut = switchConnection.errors?.out || 0;
|
||||
const statsInfo = document.createElement('div');
|
||||
statsInfo.className = 'error-info';
|
||||
let statsText = 'err: ' + errIn + '/' + errOut;
|
||||
let statsText = 'link: ' + formatLinkSpeed(switchConnection.speed);
|
||||
statsText += '\nerr: rx ' + errIn + ' / tx ' + errOut;
|
||||
if (switchConnection.rates) {
|
||||
const r = switchConnection.rates;
|
||||
statsText += '\nrx: ' + formatRate(r.outBytes) + ' (' + formatPps(r.outPkts) + ')';
|
||||
statsText += '\ntx: ' + formatRate(r.inBytes) + ' (' + formatPps(r.inPkts) + ')';
|
||||
statsText += '\nrx: ' + formatMbps(r.outBytes) + ' (' + formatPps(r.outPkts) + ')';
|
||||
statsText += '\ntx: ' + formatMbps(r.inBytes) + ' (' + formatPps(r.inPkts) + ')';
|
||||
}
|
||||
statsInfo.textContent = statsText;
|
||||
portEl.appendChild(statsInfo);
|
||||
@@ -1022,11 +1029,12 @@
|
||||
const errOut = uplinkInfo.errors?.out || 0;
|
||||
const statsInfo = document.createElement('div');
|
||||
statsInfo.className = 'error-info';
|
||||
let statsText = 'err: ' + errIn + '/' + errOut;
|
||||
let statsText = 'link: ' + formatLinkSpeed(uplinkInfo.speed);
|
||||
statsText += '\nerr: rx ' + errIn + ' / tx ' + errOut;
|
||||
if (uplinkInfo.rates) {
|
||||
const r = uplinkInfo.rates;
|
||||
statsText += '\nrx: ' + formatRate(r.inBytes) + ' (' + formatPps(r.inPkts) + ')';
|
||||
statsText += '\ntx: ' + formatRate(r.outBytes) + ' (' + formatPps(r.outPkts) + ')';
|
||||
statsText += '\nrx: ' + formatMbps(r.inBytes) + ' (' + formatPps(r.inPkts) + ')';
|
||||
statsText += '\ntx: ' + formatMbps(r.outBytes) + ' (' + formatPps(r.outPkts) + ')';
|
||||
}
|
||||
statsInfo.textContent = statsText;
|
||||
uplinkEl.appendChild(statsInfo);
|
||||
@@ -1153,6 +1161,21 @@
|
||||
typeEl.className = 'error-type';
|
||||
typeEl.textContent = 'Unreachable';
|
||||
item.appendChild(typeEl);
|
||||
} else if (err.error_type === 'high_utilization') {
|
||||
const portEl = document.createElement('div');
|
||||
portEl.className = 'error-port';
|
||||
portEl.textContent = 'Port: ' + err.port_name;
|
||||
item.appendChild(portEl);
|
||||
|
||||
const countsEl = document.createElement('div');
|
||||
countsEl.className = 'error-counts';
|
||||
countsEl.textContent = 'Utilization: ' + (err.utilization || 0).toFixed(0) + '%';
|
||||
item.appendChild(countsEl);
|
||||
|
||||
const typeEl = document.createElement('div');
|
||||
typeEl.className = 'error-type';
|
||||
typeEl.textContent = 'High link utilization';
|
||||
item.appendChild(typeEl);
|
||||
} else {
|
||||
const portEl = document.createElement('div');
|
||||
portEl.className = 'error-port';
|
||||
@@ -1161,7 +1184,7 @@
|
||||
|
||||
const countsEl = document.createElement('div');
|
||||
countsEl.className = 'error-counts';
|
||||
countsEl.textContent = 'In: ' + err.in_errors + ' (+' + (err.in_delta || 0) + ') / Out: ' + err.out_errors + ' (+' + (err.out_delta || 0) + ')';
|
||||
countsEl.textContent = 'rx: ' + err.in_errors + ' (+' + (err.in_delta || 0) + ') / tx: ' + err.out_errors + ' (+' + (err.out_delta || 0) + ')';
|
||||
item.appendChild(countsEl);
|
||||
|
||||
const typeEl = document.createElement('div');
|
||||
|
||||
Reference in New Issue
Block a user