forked from haiibo/OpenWrt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
329 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,8 @@ env: | |
REPO_URL: https://github.com/breeze303/openwrt-6.x.git | ||
REPO_BRANCH: kernel-6.8 | ||
CONFIG_FILE: configs/x86-64.config | ||
PATCHES_FILE_1: patches/0002-show-soc-status-on-luci.patch | ||
PATCHES_FILE_1: patches/0003-add-coremark-luci.patch | ||
PATCHES_FILE_2: patches/0004-add-coremark-packages.patch | ||
DIY_SCRIPT: diy-script.sh | ||
CLASH_KERNEL: amd64 | ||
CACHE_TOOLCHAIN: true | ||
|
@@ -95,6 +96,18 @@ jobs: | |
cd $OPENWRT_PATH | ||
./scripts/feeds update -a | ||
./scripts/feeds install -a | ||
- name: Apply patches(安装补丁) | ||
run: | | ||
git config --global user.name "OpenWrt Builder" | ||
git config --global user.email "[email protected]" | ||
cp $PATCHES_FILE_1 $OPENWRT_PATH/feeds/luci | ||
cp $PATCHES_FILE_2 $OPENWRT_PATH/feeds/packages | ||
cd $OPENWRT_PATH/feeds/luci | ||
git am 0003-add-coremark-luci.patch && cd - | ||
cd $OPENWRT_PATH/feeds/packages | ||
git am 0004-add-coremark-packages.patch | ||
- name: Load Custom Configuration(加载自定义配置) | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,267 @@ | ||
From 583ceb5c495074b8d18344e95f6c58269c6427ba Mon Sep 17 00:00:00 2001 | ||
From: breeze303 <[email protected]> | ||
Date: Wed, 8 May 2024 21:57:11 +0800 | ||
Subject: [PATCH] add-coremark-luci | ||
|
||
--- | ||
0002-show-soc-status-on-luci.patch | 170 ++++++++++++++++++ | ||
.../luci-base/root/usr/share/rpcd/ucode/luci | 6 + | ||
.../view/status/include/10_system.js | 13 +- | ||
.../usr/share/rpcd/acl.d/luci-mod-status.json | 2 +- | ||
4 files changed, 187 insertions(+), 4 deletions(-) | ||
create mode 100644 0002-show-soc-status-on-luci.patch | ||
|
||
diff --git a/0002-show-soc-status-on-luci.patch b/0002-show-soc-status-on-luci.patch | ||
new file mode 100644 | ||
index 0000000..ee003ca | ||
--- /dev/null | ||
+++ b/0002-show-soc-status-on-luci.patch | ||
@@ -0,0 +1,170 @@ | ||
+From d36f3bcef56a912b04670680e41cc4c729848ef1 Mon Sep 17 00:00:00 2001 | ||
+From: pexcn <[email protected]> | ||
+Date: Sun, 3 Mar 2024 15:31:06 +0800 | ||
+Subject: [PATCH] show soc status on luci | ||
+ | ||
+Signed-off-by: pexcn <[email protected]> | ||
+ | ||
+123 | ||
+ | ||
+fix bugs | ||
+--- | ||
+ modules/luci-base/root/sbin/soc-status | 36 +++++++++++++++++++ | ||
+ .../luci-base/root/usr/share/rpcd/ucode/luci | 30 ++++++++++++++++ | ||
+ .../view/status/include/10_system.js | 22 ++++++++++-- | ||
+ .../usr/share/rpcd/acl.d/luci-mod-status.json | 2 +- | ||
+ 4 files changed, 86 insertions(+), 4 deletions(-) | ||
+ create mode 100755 modules/luci-base/root/sbin/soc-status | ||
+ | ||
+diff --git a/modules/luci-base/root/sbin/soc-status b/modules/luci-base/root/sbin/soc-status | ||
+new file mode 100755 | ||
+index 0000000..1c173f7 | ||
+--- /dev/null | ||
++++ b/modules/luci-base/root/sbin/soc-status | ||
+@@ -0,0 +1,36 @@ | ||
++#!/bin/sh | ||
++# shellcheck disable=SC2155 | ||
++ | ||
++get_cpu_temp() { | ||
++ local value="$(cat /sys/class/thermal/thermal_zone*/temp 2>/dev/null | sort -n | tail -1)" | ||
++ [ -n "$value" ] || value="-1" | ||
++ echo "$value" | ||
++} | ||
++ | ||
++get_cpu_usage() { | ||
++ local value="$(top -b -n1 | awk '/^CPU/ { print 100-$8 }')" | ||
++ [ -n "$value" ] || value="-1" | ||
++ echo "$value" | ||
++} | ||
++ | ||
++get_nss_usage() { | ||
++ local value="$(grep '%' /sys/kernel/debug/qca-nss-drv/stats/cpu_load_ubi 2>/dev/null | awk '{print $2}' | sed 's/%//')" | ||
++ [ -n "$value" ] || value="-1" | ||
++ echo "$value" | ||
++} | ||
++ | ||
++case "$1" in | ||
++ cpu_temp) | ||
++ get_cpu_temp | awk '{ printf("%.1f\n", $1/1000) }' | ||
++ ;; | ||
++ cpu_usage) | ||
++ get_cpu_usage | ||
++ ;; | ||
++ nss_usage) | ||
++ get_nss_usage | ||
++ ;; | ||
++ *) | ||
++ echo "Usage: $0 {cpu_temp|cpu_usage|nss_usage}" | ||
++ exit 1 | ||
++ ;; | ||
++esac | ||
+diff --git a/modules/luci-base/root/usr/share/rpcd/ucode/luci b/modules/luci-base/root/usr/share/rpcd/ucode/luci | ||
+index 3c4fea4..7935b43 100644 | ||
+--- a/modules/luci-base/root/usr/share/rpcd/ucode/luci | ||
++++ b/modules/luci-base/root/usr/share/rpcd/ucode/luci | ||
+@@ -581,6 +581,36 @@ const methods = { | ||
+ | ||
+ return { result: ports }; | ||
+ } | ||
++ }, | ||
++ | ||
++ getCoreTemp: { | ||
++ call: function() { | ||
++ let fd; | ||
++ let result = {}; | ||
++ | ||
++ fd = popen('soc-status cpu_temp'); | ||
++ result.cpu = trim(fd.read('all')); | ||
++ fd.close(); | ||
++ | ||
++ return result; | ||
++ } | ||
++ }, | ||
++ | ||
++ getCoreUsage: { | ||
++ call: function() { | ||
++ let fd; | ||
++ let result = {}; | ||
++ | ||
++ fd = popen('soc-status cpu_usage'); | ||
++ result.cpu = trim(fd.read('all')); | ||
++ fd.close(); | ||
++ | ||
++ fd = popen('soc-status nss_usage'); | ||
++ result.nss = trim(fd.read('all')); | ||
++ fd.close(); | ||
++ | ||
++ return result; | ||
++ } | ||
+ } | ||
+ }; | ||
+ | ||
+diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js | ||
+index 45f7b4a..b83955c 100644 | ||
+--- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js | ||
++++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js | ||
+@@ -8,6 +8,16 @@ var callLuciVersion = rpc.declare({ | ||
+ method: 'getVersion' | ||
+ }); | ||
+ | ||
++var callCoreTemp = rpc.declare({ | ||
++ object: 'luci', | ||
++ method: 'getCoreTemp' | ||
++}); | ||
++ | ||
++var callCoreUsage = rpc.declare({ | ||
++ object: 'luci', | ||
++ method: 'getCoreUsage' | ||
++}); | ||
++ | ||
+ var callSystemBoard = rpc.declare({ | ||
+ object: 'system', | ||
+ method: 'board' | ||
+@@ -25,14 +35,18 @@ return baseclass.extend({ | ||
+ return Promise.all([ | ||
+ L.resolveDefault(callSystemBoard(), {}), | ||
+ L.resolveDefault(callSystemInfo(), {}), | ||
+- L.resolveDefault(callLuciVersion(), { revision: _('unknown version'), branch: 'LuCI' }) | ||
++ L.resolveDefault(callLuciVersion(), { revision: _('unknown version'), branch: 'LuCI' }), | ||
++ L.resolveDefault(callCoreTemp(), {}), | ||
++ L.resolveDefault(callCoreUsage(), {}) | ||
+ ]); | ||
+ }, | ||
+ | ||
+ render: function(data) { | ||
+ var boardinfo = data[0], | ||
+ systeminfo = data[1], | ||
+- luciversion = data[2]; | ||
++ luciversion = data[2], | ||
++ coretemp = data[3], | ||
++ coreusage = data[4]; | ||
+ | ||
+ luciversion = luciversion.branch + ' ' + luciversion.revision; | ||
+ | ||
+@@ -64,7 +78,9 @@ return baseclass.extend({ | ||
+ systeminfo.load[0] / 65535.0, | ||
+ systeminfo.load[1] / 65535.0, | ||
+ systeminfo.load[2] / 65535.0 | ||
+- ) : null | ||
++ ) : null, | ||
++ _('核心温度'), 'CPU ' + coretemp.cpu + ' °C', | ||
++ _('使用率'), 'CPU ' + coreusage.cpu + '%' + ' / ' + 'NSS ' + coreusage.nss + '%' | ||
+ ]; | ||
+ | ||
+ var table = E('table', { 'class': 'table' }); | ||
+diff --git a/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json b/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json | ||
+index 45dd7d7..127daa5 100644 | ||
+--- a/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json | ||
++++ b/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json | ||
+@@ -3,7 +3,7 @@ | ||
+ "description": "Grant access to realtime statistics", | ||
+ "read": { | ||
+ "ubus": { | ||
+- "luci": [ "getConntrackList", "getRealtimeStats" ], | ||
++ "luci": [ "getConntrackList", "getRealtimeStats", "getCoreTemp", "getCoreUsage" ], | ||
+ "network.rrdns": [ "lookup" ] | ||
+ } | ||
+ } | ||
+-- | ||
+2.34.1 | ||
+ | ||
diff --git a/modules/luci-base/root/usr/share/rpcd/ucode/luci b/modules/luci-base/root/usr/share/rpcd/ucode/luci | ||
index 7935b43..b3dc6d3 100644 | ||
--- a/modules/luci-base/root/usr/share/rpcd/ucode/luci | ||
+++ b/modules/luci-base/root/usr/share/rpcd/ucode/luci | ||
@@ -583,6 +583,12 @@ const methods = { | ||
} | ||
}, | ||
|
||
+ getCPUBench: { | ||
+ call: function() { | ||
+ return { cpubench: readfile('/etc/bench.log') || '' }; | ||
+ } | ||
+ }, | ||
+ | ||
getCoreTemp: { | ||
call: function() { | ||
let fd; | ||
diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js | ||
index b83955c..19949e2 100644 | ||
--- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js | ||
+++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js | ||
@@ -8,6 +8,11 @@ var callLuciVersion = rpc.declare({ | ||
method: 'getVersion' | ||
}); | ||
|
||
+var callCPUBench = rpc.declare({ | ||
+ object: 'luci', | ||
+ method: 'getCPUBench' | ||
+}); | ||
+ | ||
var callCoreTemp = rpc.declare({ | ||
object: 'luci', | ||
method: 'getCoreTemp' | ||
@@ -36,6 +41,7 @@ return baseclass.extend({ | ||
L.resolveDefault(callSystemBoard(), {}), | ||
L.resolveDefault(callSystemInfo(), {}), | ||
L.resolveDefault(callLuciVersion(), { revision: _('unknown version'), branch: 'LuCI' }), | ||
+ L.resolveDefault(callCPUBench(), {}), | ||
L.resolveDefault(callCoreTemp(), {}), | ||
L.resolveDefault(callCoreUsage(), {}) | ||
]); | ||
@@ -45,8 +51,9 @@ return baseclass.extend({ | ||
var boardinfo = data[0], | ||
systeminfo = data[1], | ||
luciversion = data[2], | ||
- coretemp = data[3], | ||
- coreusage = data[4]; | ||
+ cpubench = data[3], | ||
+ coretemp = data[4], | ||
+ coreusage = data[5]; | ||
|
||
luciversion = luciversion.branch + ' ' + luciversion.revision; | ||
|
||
@@ -67,7 +74,7 @@ return baseclass.extend({ | ||
|
||
var fields = [ | ||
_('Hostname'), boardinfo.hostname, | ||
- _('Model'), boardinfo.model, | ||
+ _('Model'), boardinfo.model + cpubench.cpubench, | ||
_('Architecture'), boardinfo.system, | ||
_('Target Platform'), (L.isObject(boardinfo.release) ? boardinfo.release.target : ''), | ||
_('Firmware Version'), (L.isObject(boardinfo.release) ? boardinfo.release.description + ' / ' : '') + (luciversion || ''), | ||
diff --git a/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json b/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json | ||
index 127daa5..51984d4 100644 | ||
--- a/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json | ||
+++ b/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json | ||
@@ -3,7 +3,7 @@ | ||
"description": "Grant access to realtime statistics", | ||
"read": { | ||
"ubus": { | ||
- "luci": [ "getConntrackList", "getRealtimeStats", "getCoreTemp", "getCoreUsage" ], | ||
+ "luci": [ "getConntrackList", "getRealtimeStats", "getCPUBench","getCoreTemp", "getCoreUsage" ], | ||
"network.rrdns": [ "lookup" ] | ||
} | ||
} | ||
-- | ||
2.34.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
From babdea674a730cf6df059d60bfab281767d4740f Mon Sep 17 00:00:00 2001 | ||
From: breeze303 <[email protected]> | ||
Date: Wed, 8 May 2024 22:10:07 +0800 | ||
Subject: [PATCH] add-coremark-packages | ||
|
||
--- | ||
utils/coremark/coremark | 7 +++++++ | ||
utils/coremark/coremark.sh | 12 ++++++++++++ | ||
2 files changed, 19 insertions(+) | ||
create mode 100644 utils/coremark/coremark | ||
create mode 100644 utils/coremark/coremark.sh | ||
|
||
diff --git a/utils/coremark/coremark b/utils/coremark/coremark | ||
new file mode 100644 | ||
index 000000000..2fcdd544b | ||
--- /dev/null | ||
+++ b/utils/coremark/coremark | ||
@@ -0,0 +1,7 @@ | ||
+#!/bin/sh | ||
+ | ||
+sed -i '/coremark/d' /etc/crontabs/root | ||
+echo "0 4 * * * /etc/coremark.sh" >> /etc/crontabs/root | ||
+crontab /etc/crontabs/root | ||
+ | ||
+touch /etc/bench.log | ||
\ No newline at end of file | ||
diff --git a/utils/coremark/coremark.sh b/utils/coremark/coremark.sh | ||
new file mode 100644 | ||
index 000000000..e581b7c92 | ||
--- /dev/null | ||
+++ b/utils/coremark/coremark.sh | ||
@@ -0,0 +1,12 @@ | ||
+#!/bin/sh | ||
+ | ||
+/bin/coremark > /tmp/coremark.log | ||
+ | ||
+cat /tmp/coremark.log | grep "CoreMark 1.0" | cut -d "/" -f 1 > /etc/bench.log | ||
+sed -i 's/CoreMark 1.0/ (CpuMark/g' /etc/bench.log | ||
+echo " Scores)" >> /etc/bench.log | ||
+ | ||
+if [ -f "/etc/bench.log" ]; then | ||
+ sed -i '/coremark/d' /etc/crontabs/root | ||
+ crontab /etc/crontabs/root | ||
+fi | ||
\ No newline at end of file | ||
-- | ||
2.34.1 | ||
|