From fae773b25aa8407e9fe57c2a57bf8a4e7f54639c Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 12 Dec 2022 12:05:57 -0500 Subject: [PATCH] [WIFI-10957] Device statistics now using SSID counters when displaying upstream interfaces Signed-off-by: Charles --- package-lock.json | 4 ++-- package.json | 2 +- src/hooks/Network/Statistics.ts | 12 ++++++++++++ .../Device/StatisticsCard/useStatisticsCard.ts | 13 +++++++++++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 01e0754..04fed89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ucentral-client", - "version": "2.8.0(40)", + "version": "2.8.0(41)", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ucentral-client", - "version": "2.8.0(40)", + "version": "2.8.0(41)", "license": "ISC", "dependencies": { "@chakra-ui/icons": "^2.0.11", diff --git a/package.json b/package.json index 8d0dba1..17f93de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ucentral-client", - "version": "2.8.0(40)", + "version": "2.8.0(41)", "description": "", "private": true, "main": "index.tsx", diff --git a/src/hooks/Network/Statistics.ts b/src/hooks/Network/Statistics.ts index 7a17694..d02c629 100644 --- a/src/hooks/Network/Statistics.ts +++ b/src/hooks/Network/Statistics.ts @@ -64,6 +64,18 @@ type DeviceInterfaceStatistics = { }; tx_retries: number; }[]; + counters?: { + collisions: number; + multicast: number; + rx_bytes: number; + rx_dropped: number; + rx_errors: number; + rx_packets: number; + tx_bytes: number; + tx_dropped: number; + tx_errors: number; + tx_packets: number; + }; bssid: string; iface: string; location: string; diff --git a/src/pages/Device/StatisticsCard/useStatisticsCard.ts b/src/pages/Device/StatisticsCard/useStatisticsCard.ts index 34f15e0..9ea4932 100644 --- a/src/pages/Device/StatisticsCard/useStatisticsCard.ts +++ b/src/pages/Device/StatisticsCard/useStatisticsCard.ts @@ -73,8 +73,17 @@ export const useStatisticsCard = ({ serialNumber }: Props) => { memoryData.recorded.push(stat.recorded); for (const inter of stat.data.interfaces ?? []) { - const rx = inter.counters?.rx_bytes ?? 0; - const tx = inter.counters?.tx_bytes ?? 0; + const isInterUpstream = inter.name?.substring(0, 2) === 'up'; + let rx = inter.counters?.rx_bytes ?? 0; + let tx = inter.counters?.tx_bytes ?? 0; + + if (isInterUpstream) { + for (const ssid of inter.ssids ?? []) { + rx += ssid.counters?.rx_bytes ?? 0; + tx += ssid.counters?.tx_bytes ?? 0; + } + } + let rxDelta = rx - (previousRx[inter.name] ?? 0); if (rxDelta < 0) rxDelta = 0; let txDelta = tx - (previousTx[inter.name] ?? 0);