2.6.14: statistics fix for devices with more than one interface

This commit is contained in:
Charles
2022-04-19 15:51:00 +01:00
parent 6bec9f977f
commit b75848515b
3 changed files with 25 additions and 23 deletions

View File

@@ -124,19 +124,21 @@ const StatisticsChartList = ({ setOptions, section, setStart, setEnd, time }) =>
}
// Looping through all the data
let prevTx = 0;
let prevRx = 0;
const prevTxObj = {};
const prevRxObj = {};
for (const log of sortedData) {
// Looping through the interfaces of the log
const version = log.data.version ?? 0;
for (const inter of log.data.interfaces) {
if (version > 0) {
const tx = inter.counters ? Math.floor(inter.counters.tx_bytes) : 0;
const rx = inter.counters ? Math.floor(inter.counters.rx_bytes) : 0;
interfaceList[interfaceTypes[inter.name]][0].data.push(tx - prevTx);
interfaceList[interfaceTypes[inter.name]][1].data.push(rx - prevRx);
prevTx = tx;
prevRx = rx;
const prevTx = prevTxObj[inter.name] !== undefined ? prevTxObj[inter.name] : 0;
const prevRx = prevTxObj[inter.name] !== undefined ? prevRxObj[inter.name] : 0;
const tx = inter.counters ? inter.counters.tx_bytes : 0;
const rx = inter.counters ? inter.counters.rx_bytes : 0;
interfaceList[interfaceTypes[inter.name]][0].data.push(Math.max(0, tx - prevTx));
interfaceList[interfaceTypes[inter.name]][1].data.push(Math.max(0, rx - prevRx));
prevTxObj[inter.name] = tx;
prevRxObj[inter.name] = rx;
} else {
interfaceList[interfaceTypes[inter.name]][0].data.push(
inter.counters ? Math.floor(inter.counters.tx_bytes) : 0,