From a0ba5aeca4e8eca5bdca5321e6e8ac9889cb201f Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 18 Jan 2022 11:10:13 +0100 Subject: [PATCH] 2.5.28: added deltas as possible source of tx/rx from associations --- package-lock.json | 4 +-- package.json | 2 +- .../StatisticsChartList.js | 36 +++++++++++++++---- src/components/WifiAnalysis/index.js | 2 +- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1b7d9c2..c162bec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ucentral-client", - "version": "2.5.27", + "version": "2.5.28", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ucentral-client", - "version": "2.5.27", + "version": "2.5.28", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/package.json b/package.json index 23502da..c5c3ff6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ucentral-client", - "version": "2.5.27", + "version": "2.5.28", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/src/components/InterfaceStatistics/StatisticsChartList.js b/src/components/InterfaceStatistics/StatisticsChartList.js index 5221334..e40c0bc 100644 --- a/src/components/InterfaceStatistics/StatisticsChartList.js +++ b/src/components/InterfaceStatistics/StatisticsChartList.js @@ -117,12 +117,36 @@ const StatisticsChartList = ({ setOptions, section, setStart, setEnd, time }) => for (const log of sortedData) { // Looping through the interfaces of the log for (const inter of log.data.interfaces) { - interfaceList[interfaceTypes[inter.name]][0].data.push( - inter.counters?.tx_bytes ? Math.floor(inter.counters.tx_bytes / 1024) : 0, - ); - interfaceList[interfaceTypes[inter.name]][1].data.push( - inter.counters?.rx_bytes ? Math.floor(inter.counters.rx_bytes / 1024) : 0, - ); + if (inter.counters) { + interfaceList[interfaceTypes[inter.name]][0].data.push( + inter.counters?.tx_bytes ? Math.floor(inter.counters.tx_bytes / 1024) : 0, + ); + interfaceList[interfaceTypes[inter.name]][1].data.push( + inter.counters?.rx_bytes ? Math.floor(inter.counters.rx_bytes / 1024) : 0, + ); + } else if ( + inter.ssids.length > 0 && + inter.ssids[0].associations.length > 0 && + inter.ssids[0].associations[0].deltas + ) { + let totalTx = 0; + let totalRx = 0; + + for (const ssid of inter.ssids) { + for (const assoc of ssid.associations) { + totalTx += assoc.deltas?.tx_bytes ?? 0; + totalRx += assoc.deltas?.rx_bytes ?? 0; + } + } + totalTx = Math.floor(totalTx / 1024); + totalRx = Math.floor(totalRx / 1024); + + interfaceList[interfaceTypes[inter.name]][0].data.push(totalTx); + interfaceList[interfaceTypes[inter.name]][1].data.push(totalRx); + } else { + interfaceList[interfaceTypes[inter.name]][0].data.push(0); + interfaceList[interfaceTypes[inter.name]][1].data.push(0); + } } } diff --git a/src/components/WifiAnalysis/index.js b/src/components/WifiAnalysis/index.js index 6b3e946..62a2a50 100644 --- a/src/components/WifiAnalysis/index.js +++ b/src/components/WifiAnalysis/index.js @@ -120,7 +120,7 @@ const WifiAnalysis = () => { // Looping through the interfaces for (const deviceInterface of stat.data.interfaces) { - if ('counters' in deviceInterface && 'ssids' in deviceInterface) { + if ('ssids' in deviceInterface) { for (const ssid of deviceInterface.ssids) { // Information common between all associations const radioInfo = {