Skip to content

Commit aeb660b

Browse files
committed
autocore: add nss usage display on index
1 parent 2fc5d80 commit aeb660b

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

package/lean/autocore/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ define Package/autocore-arm/install
4747
$(INSTALL_DIR) $(1)/sbin
4848
$(INSTALL_BIN) ./files/arm/sbin/cpuinfo $(1)/sbin/cpuinfo
4949
$(INSTALL_BIN) ./files/arm/sbin/ethinfo $(1)/sbin/ethinfo
50+
$(INSTALL_BIN) ./files/arm/sbin/usage $(1)/sbin/usage
5051
endef
5152

5253
define Package/autocore-x86/install

package/lean/autocore/files/arm/index.htm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
local has_dhcp = fs.access("/etc/config/dhcp")
1616
local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0)
1717
local has_switch = false
18-
18+
1919
uci:foreach("network", "switch",
2020
function(s)
2121
has_switch = true
@@ -32,7 +32,7 @@
3232
buffered = 0,
3333
shared = 0
3434
}
35-
35+
3636
local mem_cached = luci.sys.exec("sed -e '/^Cached: /!d; s#Cached: *##; s# kB##g' /proc/meminfo")
3737

3838
local swapinfo = sysinfo.swap or {
@@ -56,8 +56,8 @@
5656

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

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

6363
local rv = {
@@ -162,7 +162,7 @@
162162
if (ht) s += ', MCS %s'.format(mcs);
163163
if (sgi) s += ', <%:Short GI%>';
164164
}
165-
165+
166166
if (he) {
167167
s += ', HE-MCS %d'.format(mcs);
168168
if (nss) s += ', HE-NSS %d'.format(nss);
@@ -265,7 +265,7 @@
265265
'<strong><%:Type%>: </strong>%s%s<br />',
266266
ifc6.proto, (ifc6.ip6prefix) ? '-pd' : ''
267267
);
268-
268+
269269
if (!ifc6.ip6prefix)
270270
{
271271
s += String.format(
@@ -652,7 +652,7 @@
652652
<% end %>
653653

654654
var e;
655-
655+
656656
if (e = document.getElementById('ethinfo')) {
657657
var ports = eval('(' + info.ethinfo + ')');
658658
var tmp = "";
@@ -672,10 +672,10 @@
672672

673673
if (e = document.getElementById('uptime'))
674674
e.innerHTML = String.format('%t', info.uptime);
675-
675+
676676
if (e = document.getElementById('userinfo'))
677677
e.innerHTML = info.userinfo;
678-
678+
679679
if (e = document.getElementById('cpuusage'))
680680
e.innerHTML = info.cpuusage;
681681

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
NSS_PATH="/sys/kernel/debug/qca-nss-drv/stats"
4+
5+
cpu_usage="$(top -n1 | awk '/^CPU/ {printf("%d%", 100 - $8)}')"
6+
7+
[ ! -d "$NSS_PATH" ] || \
8+
npu_usage="$(grep '%' "$NSS_PATH"/cpu_load_ubi | awk -F ' ' '{print $2}')"
9+
10+
if [ -d "$NSS_PATH" ]; then
11+
echo -n "CPU: ${cpu_usage}%, NPU: ${npu_usage}"
12+
else
13+
echo -n "CPU: ${cpu_usage}%"
14+
fi

0 commit comments

Comments
 (0)