From 55097d4f7ca7618336372a9d46af970f38bd0d2a Mon Sep 17 00:00:00 2001 From: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com> Date: Fri, 25 Sep 2020 11:25:09 +0800 Subject: [PATCH] autocore: enable sensors support for ipq806x --- package/lean/autocore/Makefile | 6 ++++-- package/lean/autocore/files/arm/index.htm | 6 +++++- package/lean/autocore/files/arm/sbin/cpuinfo | 12 ++++++++---- package/lean/autocore/files/arm/sbin/tempinfo | 6 ++++++ 4 files changed, 23 insertions(+), 7 deletions(-) create mode 100755 package/lean/autocore/files/arm/sbin/tempinfo diff --git a/package/lean/autocore/Makefile b/package/lean/autocore/Makefile index b10064baed..1fe5c9f2e1 100644 --- a/package/lean/autocore/Makefile +++ b/package/lean/autocore/Makefile @@ -17,8 +17,7 @@ define Package/autocore-arm TITLE:=Arm auto core loadbalance script. MAINTAINER:=CN_SZTL DEPENDS:=@(TARGET_bcm27xx||TARGET_bcm53xx||TARGET_ipq40xx||TARGET_ipq806x) \ - +TARGET_bcm53xx:nvram \ - +TARGET_ipq40xx:lm-sensors + +TARGET_bcm53xx:nvram +(TARGET_ipq40xx||TARGET_ipq806x):lm-sensors VARIANT:=arm endef @@ -47,6 +46,9 @@ define Package/autocore-arm/install $(INSTALL_BIN) ./files/arm/090-cover-index_htm $(1)/etc/uci-defaults/090-cover-index_htm $(INSTALL_DIR) $(1)/sbin $(INSTALL_BIN) ./files/arm/sbin/cpuinfo $(1)/sbin/cpuinfo +ifeq ($(BOARD),ipq806x) + $(INSTALL_BIN) ./files/arm/sbin/tempinfo $(1)/sbin/tempinfo +endif endef define Package/autocore-x86/install diff --git a/package/lean/autocore/files/arm/index.htm b/package/lean/autocore/files/arm/index.htm index ff979fc9e8..0a348fe462 100644 --- a/package/lean/autocore/files/arm/index.htm +++ b/package/lean/autocore/files/arm/index.htm @@ -13,6 +13,7 @@ local has_ipv6 = fs.access("/usr/sbin/ip6tables") local has_dhcp = fs.access("/etc/config/dhcp") local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0) + local has_temp = fs.access("/sbin/tempinfo") local sysinfo = luci.util.ubus("system", "info") or { } local boardinfo = luci.util.ubus("system", "board") or { } @@ -49,7 +50,7 @@ local user_info = luci.sys.exec("cat /proc/net/arp | grep 'br-lan' | grep '0x2' | wc -l") local cpu_usage = (luci.sys.exec("expr 100 - $(top -n 1 | grep 'CPU:' | awk -F '%' '{print$4}' | awk -F ' ' '{print$2}')") or "6") .. "%" - local cpu_info = luci.sys.exec("/sbin/cpuinfo") or "ARM Processor x 0 (233MHz, 2.3°C)" + local cpu_info = luci.sys.exec("/sbin/cpuinfo") or "ARM Processor" local rv = { cpuinfo = cpu_info, @@ -705,6 +706,9 @@ <%:Local Time%>- <%:Uptime%>- <%:Load Average%>- + <% if has_temp then %> + <%:Temperature%><%=luci.sys.exec("/sbin/tempinfo") or "?"%> + <% end %> <%:CPU usage (%)%>- diff --git a/package/lean/autocore/files/arm/sbin/cpuinfo b/package/lean/autocore/files/arm/sbin/cpuinfo index 3b870290da..83df4c6238 100755 --- a/package/lean/autocore/files/arm/sbin/cpuinfo +++ b/package/lean/autocore/files/arm/sbin/cpuinfo @@ -10,10 +10,14 @@ else cpu_freq="$(expr $(cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq) / 1000)MHz" fi -if grep -q "ipq40xx" "/etc/openwrt_release"; then - sys_temp="$(sensors | grep -Eo '\+[0-9]+.+C' | sed ':a;N;$!ba;s/\n/ /g;s/+//g')" +if grep -q "ipq" "/etc/openwrt_release"; then + if grep -q "ipq40xx" "/etc/openwrt_release"; then + sys_temp="$(sensors | grep -Eo '\+[0-9]+.+C' | sed ':a;N;$!ba;s/\n/ /g;s/+//g')" + echo -n "${cpu_arch} x ${cpu_cores} (${cpu_freq}, ${sys_temp})" + else + echo -n "${cpu_arch} x ${cpu_cores} (${cpu_freq})" + fi else sys_temp="$(awk "BEGIN{printf (\"%.1f\n\",$(cat /sys/class/thermal/thermal_zone0/temp)/1000) }")°C" + echo -n "${cpu_arch} x ${cpu_cores} (${cpu_freq}, ${sys_temp})" fi - -echo -n "${cpu_arch} x ${cpu_cores} (${cpu_freq}, ${sys_temp})" diff --git a/package/lean/autocore/files/arm/sbin/tempinfo b/package/lean/autocore/files/arm/sbin/tempinfo new file mode 100755 index 0000000000..b42151d0e6 --- /dev/null +++ b/package/lean/autocore/files/arm/sbin/tempinfo @@ -0,0 +1,6 @@ +#!/bin/sh + +cpu_temp="$(awk "BEGIN{printf (\"%.1f\n\",$(cat /sys/class/thermal/thermal_zone0/temp)/1000) }")°C" +sys_temp="$(sensors | grep -Eo '\+[0-9]+.+C' | grep -Ev 'high' | sed ':a;N;$!ba;s/\n/ /g;s/+//g')" + +echo -n "CPU: ${cpu_temp}, WiFi: ${sys_temp}"