Add port statistics page

This commit is contained in:
logicog
2025-08-19 09:27:24 +02:00
parent 72d8f3639c
commit 41b181d9fb
2 changed files with 48 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<script src="/ports.js"></script>
<script src="/main.js"></script>
<head>
<link rel="stylesheet" href="style.css">
<title>FreeSwitchOS Port Statistics</title>
</head>
<body>
<ul> <li><a href="index.html">Overview</a></li> <li><a href="stat.html">Port Statisitcs</a></li>
<li><a href="vlan.html">VLAN</a></li> <li><a href="mirror.html">Mirroring</a></li>
<li><a href="trunk.html">Port Aggregation</a></li></ul>
<div style="margin-left:16%;padding:1px 16px;height:1000px;">
<div id="ports"></div>
<h1>Port Statistics</h1>
<table id="statstable">
<tr> <th>Port</th> <th>link</th> <th>TX Good</th> <th>TX Bad</th> <th>RX Good</th> <th>RX Bad</th> </tr>
<script src="/stat.js"></script>
</table>
</div>
</body>
</html>
+26
View File
@@ -0,0 +1,26 @@
function fillStats() {
var tbl = document.getElementById('statstable');
if (tbl.rows.length > 1) {
for (let i = 0; i < 6; i++) {
console.log("Table Update row: " + i + " state " + pState[i] + " is " + linkS[pState[i] +1]);
tbl.rows[i+1].cells[1].innerHTML = `${linkS[pState[i]+1]}`;
tbl.rows[i+1].cells[2].innerHTML = `${txG[i]} Byte`;
tbl.rows[i+1].cells[3].innerHTML = `${txB[i]} Byte`;
tbl.rows[i+1].cells[4].innerHTML = `${rxG[i]} Byte`;
tbl.rows[i+1].cells[5].innerHTML = `${rxB[i]} Byte`;
}
} else {
for (let i = 0; i < 6; i++) {
console.log("Table row: " + i);
const tr = tbl.insertRow();
let td = tr.insertCell(); td.appendChild(document.createTextNode(`Port ${i+1}`));
td = tr.insertCell(); td.appendChild(document.createTextNode(`${linkS[pState[i]+1]}`));
td = tr.insertCell(); td.appendChild(document.createTextNode(`${txG[i]} Byte`));
td = tr.insertCell();td.appendChild(document.createTextNode(`${txB[i]} Byte`));
td = tr.insertCell();td.appendChild(document.createTextNode(`${rxG[i]} Byte`));
td = tr.insertCell();td.appendChild(document.createTextNode(`${rxB[i]} Byte`));
}
}
}
const stat = setInterval(fillStats, 500);