Skip to content

Commit

Permalink
autocore: add nss usage display on index
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsnowwolf committed Jun 14, 2024
1 parent 2fc5d80 commit aeb660b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions package/lean/autocore/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ define Package/autocore-arm/install
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) ./files/arm/sbin/cpuinfo $(1)/sbin/cpuinfo
$(INSTALL_BIN) ./files/arm/sbin/ethinfo $(1)/sbin/ethinfo
$(INSTALL_BIN) ./files/arm/sbin/usage $(1)/sbin/usage
endef

define Package/autocore-x86/install
Expand Down
18 changes: 9 additions & 9 deletions package/lean/autocore/files/arm/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
local has_dhcp = fs.access("/etc/config/dhcp")
local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0)
local has_switch = false

uci:foreach("network", "switch",
function(s)
has_switch = true
Expand All @@ -32,7 +32,7 @@
buffered = 0,
shared = 0
}

local mem_cached = luci.sys.exec("sed -e '/^Cached: /!d; s#Cached: *##; s# kB##g' /proc/meminfo")

local swapinfo = sysinfo.swap or {
Expand All @@ -56,8 +56,8 @@

local user_info = luci.sys.exec("cat /proc/net/arp | grep 'br-lan' | grep '0x2' | wc -l")

local cpu_usage = luci.sys.exec("top -n1 | awk '/^CPU/ { printf(\"%d%%\", 100 - $8) }'") or "6%"
local cpu_info = luci.sys.exec("/sbin/cpuinfo") or "ARM Processor x 0 (233MHz, 2.3°C)"
local cpu_usage = luci.sys.exec("/sbin/usage") or "6%"
local cpu_info = luci.sys.exec("/sbin/cpuinfo") or "?"
local eth_info = luci.sys.exec("ethinfo")

local rv = {
Expand Down Expand Up @@ -162,7 +162,7 @@
if (ht) s += ', MCS %s'.format(mcs);
if (sgi) s += ', <%:Short GI%>';
}

if (he) {
s += ', HE-MCS %d'.format(mcs);
if (nss) s += ', HE-NSS %d'.format(nss);
Expand Down Expand Up @@ -265,7 +265,7 @@
'<strong><%:Type%>: </strong>%s%s<br />',
ifc6.proto, (ifc6.ip6prefix) ? '-pd' : ''
);

if (!ifc6.ip6prefix)
{
s += String.format(
Expand Down Expand Up @@ -652,7 +652,7 @@
<% end %>

var e;

if (e = document.getElementById('ethinfo')) {
var ports = eval('(' + info.ethinfo + ')');
var tmp = "";
Expand All @@ -672,10 +672,10 @@

if (e = document.getElementById('uptime'))
e.innerHTML = String.format('%t', info.uptime);

if (e = document.getElementById('userinfo'))
e.innerHTML = info.userinfo;

if (e = document.getElementById('cpuusage'))
e.innerHTML = info.cpuusage;

Expand Down
14 changes: 14 additions & 0 deletions package/lean/autocore/files/arm/sbin/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

NSS_PATH="/sys/kernel/debug/qca-nss-drv/stats"

cpu_usage="$(top -n1 | awk '/^CPU/ {printf("%d%", 100 - $8)}')"

[ ! -d "$NSS_PATH" ] || \
npu_usage="$(grep '%' "$NSS_PATH"/cpu_load_ubi | awk -F ' ' '{print $2}')"

if [ -d "$NSS_PATH" ]; then
echo -n "CPU: ${cpu_usage}%, NPU: ${npu_usage}"
else
echo -n "CPU: ${cpu_usage}%"
fi

0 comments on commit aeb660b

Please sign in to comment.