autocore: implement tempinfo display

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
(cherry picked from commit a5b55edeee329e2c469cd960f6d4bb8dfab57554)
This commit is contained in:
Tianling Shen 2022-03-26 20:01:30 +08:00
parent 51225d75e4
commit a3dc82e4d1
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
6 changed files with 54 additions and 2 deletions

View File

@ -14,6 +14,7 @@ PKG_CONFIG_DEPENDS:= \
CONFIG_TARGET_bcm53xx CONFIG_TARGET_bcm53xx
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/target.mk
define Package/autocore-arm define Package/autocore-arm
TITLE:=ARM auto core script. TITLE:=ARM auto core script.
@ -55,6 +56,10 @@ endef
define Package/autocore-arm/install define Package/autocore-arm/install
$(call Package/autocore/install/Default,$(1)) $(call Package/autocore/install/Default,$(1))
ifneq ($(filter ipq% %mt7622, $(TARGETID)),)
$(INSTALL_BIN) ./files/arm/tempinfo $(1)/sbin/
endif
endef endef
define Package/autocore-x86/install define Package/autocore-x86/install

View File

@ -0,0 +1,21 @@
#!/bin/sh
IEEE_PATH="/sys/class/ieee80211"
THERMAL_PATH="/sys/class/thermal"
if [ -e "$IEEE_PATH/phy0/hwmon0/temp1_input" ]; then
mt76_temp=" $(awk -F ': ' '{print $2}' "$IEEE_PATH/phy0/hwmon0/temp1_input")°C"
fi
if grep -Eq "ipq40xx|ipq806x" "/etc/openwrt_release"; then
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/device/hwmon/hwmon*/temp1_input | awk '$1=$1')"
else
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/hwmon*/temp1_input | awk '$1=$1')"
fi
if grep -q "ipq40xx" "/etc/openwrt_release"; then
echo -n "WiFi:${mt76_temp} ${wifi_temp}"
else
cpu_temp="$(awk '{printf("%.1f°C", $0 / 1000)}' "$THERMAL_PATH/thermal_zone0/temp")"
echo -n "CPU: ${cpu_temp}, WiFi: ${wifi_temp}"
fi

View File

@ -28,6 +28,11 @@ var callCPUUsage = rpc.declare({
method: 'getCPUUsage' method: 'getCPUUsage'
}); });
var callTempInfo = rpc.declare({
object: 'luci',
method: 'getTempInfo'
});
return baseclass.extend({ return baseclass.extend({
title: _('System'), title: _('System'),
@ -38,6 +43,7 @@ return baseclass.extend({
L.resolveDefault(callCPUBench(), {}), L.resolveDefault(callCPUBench(), {}),
L.resolveDefault(callCPUInfo(), {}), L.resolveDefault(callCPUInfo(), {}),
L.resolveDefault(callCPUUsage(), {}), L.resolveDefault(callCPUUsage(), {}),
L.resolveDefault(callTempInfo(), {}),
fs.lines('/usr/lib/lua/luci/version.lua') fs.lines('/usr/lib/lua/luci/version.lua')
]); ]);
}, },
@ -48,7 +54,8 @@ return baseclass.extend({
cpubench = data[2], cpubench = data[2],
cpuinfo = data[3], cpuinfo = data[3],
cpuusage = data[4], cpuusage = data[4],
luciversion = data[5]; tempinfo = data[5],
luciversion = data[6];
luciversion = luciversion.filter(function(l) { luciversion = luciversion.filter(function(l) {
return l.match(/^\s*(luciname|luciversion)\s*=/); return l.match(/^\s*(luciname|luciversion)\s*=/);
@ -88,6 +95,11 @@ return baseclass.extend({
_('CPU usage (%)'), cpuusage.cpuusage _('CPU usage (%)'), cpuusage.cpuusage
]; ];
if (tempinfo.tempinfo) {
fields.splice(6, 0, _('Temperature'));
fields.splice(7, 0, tempinfo.tempinfo);
}
var table = E('table', { 'class': 'table' }); var table = E('table', { 'class': 'table' });
for (var i = 0; i < fields.length; i += 2) { for (var i = 0; i < fields.length; i += 2) {

View File

@ -51,7 +51,8 @@ esac
if [ -z "$big_cpu_freq$cpu_freq" ] && [ -n "$cpu_temp" ]; then if [ -z "$big_cpu_freq$cpu_freq" ] && [ -n "$cpu_temp" ]; then
echo -n "$cpu_arch x $cpu_cores ($cpu_temp)" echo -n "$cpu_arch x $cpu_cores ($cpu_temp)"
elif [ -z "$cpu_temp" ] && [ -n "$big_cpu_freq$cpu_freq" ]; then elif [ -z "$cpu_temp" ] && [ -n "$big_cpu_freq$cpu_freq" ] || \
grep -Eq "ipq|mt7622" "/etc/openwrt_release"; then
echo -n "$cpu_arch x $cpu_cores ($big_cpu_freq$cpu_freq)" echo -n "$cpu_arch x $cpu_cores ($big_cpu_freq$cpu_freq)"
elif [ -n "$cpu_temp" ] && [ -n "$big_cpu_freq$cpu_freq" ]; then elif [ -n "$cpu_temp" ] && [ -n "$big_cpu_freq$cpu_freq" ]; then
echo -n "$cpu_arch x $cpu_cores ($big_cpu_freq$cpu_freq, ${cpu_temp})" echo -n "$cpu_arch x $cpu_cores ($big_cpu_freq$cpu_freq, ${cpu_temp})"

View File

@ -672,6 +672,16 @@ local methods = {
return onlineusers return onlineusers
end end
},
getTempInfo = {
call = function()
local sys = require "luci.sys"
local tempinfo = {}
tempinfo.tempinfo = sys.exec("/sbin/tempinfo 2>/dev/null")
return tempinfo
end
} }
} }

View File

@ -98,3 +98,6 @@ msgstr "半双工"
msgid "Allow AP mode to disconnect STAs based on low ACK condition" msgid "Allow AP mode to disconnect STAs based on low ACK condition"
msgstr "允许 AP 模式基于低 ACK 条件判断剔除弱信号的客户端" msgstr "允许 AP 模式基于低 ACK 条件判断剔除弱信号的客户端"
msgid "Temperature"
msgstr "温度"