From 5c4eb1c3b75d52871d8a202a8ab9eae8e4dac0e1 Mon Sep 17 00:00:00 2001 From: Sean Khan Date: Sun, 23 Jun 2024 16:43:54 -0400 Subject: [PATCH] qca-nss-drv: Improve nss_stats script allow users to specify specific metric to view, rather than everything Available stats objects: cpu crypto_cmn dma drv dynamic_if edma eth_rx ipv4 ipv6 n2h unaligned virt_if wifi_ext_vdev wifi mesh Usage: nss_stats obj1 obj2 ... Default with no parameters shows all Signed-off-by: Sean Khan --- qca-nss-drv/files/qca-nss-drv.debug | 77 +++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/qca-nss-drv/files/qca-nss-drv.debug b/qca-nss-drv/files/qca-nss-drv.debug index 2e911d7..ba583a4 100755 --- a/qca-nss-drv/files/qca-nss-drv.debug +++ b/qca-nss-drv/files/qca-nss-drv.debug @@ -1,24 +1,26 @@ #!/bin/sh -# shellcheck disable=2046 +# shellcheck disable=2046,3037,3010 ############################################################################### # QCA NSS Driver Debug Script -# version 20240228 +# version 20240622 # # Requires: NSS Driver 12.1+ # Usage: /lib/debug/qca-nss-drv (no arguments) # Description: Display non-zero NSS statistics with color highlighting # (requires a terminal that supports ANSI escape codes) # -# Maintainer: Qosmio (https://forum.openwrt.org/u/qosmio) -# NSS Packages Repository: https://github.com/qosmio/nss-packages (branch: NSS-12.4-K6.1) +# Maintainer: Sean Khan (https://forum.openwrt.org/u/qosmio) +# NSS Packages Repository: https://github.com/qosmio/nss-packages (branch: NSS-12.5-K6.x) # - -current=$(sysctl -q -n dev.nss.stats.non_zero_stats) -sysctl -q dev.nss.stats.non_zero_stats=1 - -awk ' +color() { + awk ' function color(c, s) { if ($3 > 0) { + if ($3 ~ /^[0-9]+/ && $3 > 0 && $0 ~ /%/ ) c = 3 + if ($2 ~ /Avg/ ) c = 4 + if ($1 ~ /\#/ ) c = 7 + if ($3 ~ /^[0-9]+$/ && $3 > 0 && $0 ~ /\=/ ) c = 3 + if ($0 ~ /<