autocore: implement tempinfo display
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org> (cherry picked from commit a5b55edeee329e2c469cd960f6d4bb8dfab57554)
This commit is contained in:
parent
51225d75e4
commit
a3dc82e4d1
@ -14,6 +14,7 @@ PKG_CONFIG_DEPENDS:= \
|
||||
CONFIG_TARGET_bcm53xx
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/target.mk
|
||||
|
||||
define Package/autocore-arm
|
||||
TITLE:=ARM auto core script.
|
||||
@ -55,6 +56,10 @@ endef
|
||||
|
||||
define Package/autocore-arm/install
|
||||
$(call Package/autocore/install/Default,$(1))
|
||||
|
||||
ifneq ($(filter ipq% %mt7622, $(TARGETID)),)
|
||||
$(INSTALL_BIN) ./files/arm/tempinfo $(1)/sbin/
|
||||
endif
|
||||
endef
|
||||
|
||||
define Package/autocore-x86/install
|
||||
|
21
package/emortal/autocore/files/arm/tempinfo
Executable file
21
package/emortal/autocore/files/arm/tempinfo
Executable 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
|
@ -28,6 +28,11 @@ var callCPUUsage = rpc.declare({
|
||||
method: 'getCPUUsage'
|
||||
});
|
||||
|
||||
var callTempInfo = rpc.declare({
|
||||
object: 'luci',
|
||||
method: 'getTempInfo'
|
||||
});
|
||||
|
||||
return baseclass.extend({
|
||||
title: _('System'),
|
||||
|
||||
@ -38,6 +43,7 @@ return baseclass.extend({
|
||||
L.resolveDefault(callCPUBench(), {}),
|
||||
L.resolveDefault(callCPUInfo(), {}),
|
||||
L.resolveDefault(callCPUUsage(), {}),
|
||||
L.resolveDefault(callTempInfo(), {}),
|
||||
fs.lines('/usr/lib/lua/luci/version.lua')
|
||||
]);
|
||||
},
|
||||
@ -48,7 +54,8 @@ return baseclass.extend({
|
||||
cpubench = data[2],
|
||||
cpuinfo = data[3],
|
||||
cpuusage = data[4],
|
||||
luciversion = data[5];
|
||||
tempinfo = data[5],
|
||||
luciversion = data[6];
|
||||
|
||||
luciversion = luciversion.filter(function(l) {
|
||||
return l.match(/^\s*(luciname|luciversion)\s*=/);
|
||||
@ -88,6 +95,11 @@ return baseclass.extend({
|
||||
_('CPU usage (%)'), cpuusage.cpuusage
|
||||
];
|
||||
|
||||
if (tempinfo.tempinfo) {
|
||||
fields.splice(6, 0, _('Temperature'));
|
||||
fields.splice(7, 0, tempinfo.tempinfo);
|
||||
}
|
||||
|
||||
var table = E('table', { 'class': 'table' });
|
||||
|
||||
for (var i = 0; i < fields.length; i += 2) {
|
||||
|
@ -51,7 +51,8 @@ esac
|
||||
|
||||
if [ -z "$big_cpu_freq$cpu_freq" ] && [ -n "$cpu_temp" ]; then
|
||||
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)"
|
||||
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})"
|
||||
|
@ -672,6 +672,16 @@ local methods = {
|
||||
return onlineusers
|
||||
|
||||
end
|
||||
},
|
||||
|
||||
getTempInfo = {
|
||||
call = function()
|
||||
local sys = require "luci.sys"
|
||||
local tempinfo = {}
|
||||
|
||||
tempinfo.tempinfo = sys.exec("/sbin/tempinfo 2>/dev/null")
|
||||
return tempinfo
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,3 +98,6 @@ msgstr "半双工"
|
||||
|
||||
msgid "Allow AP mode to disconnect STAs based on low ACK condition"
|
||||
msgstr "允许 AP 模式基于低 ACK 条件判断剔除弱信号的客户端"
|
||||
|
||||
msgid "Temperature"
|
||||
msgstr "温度"
|
||||
|
Loading…
x
Reference in New Issue
Block a user