Closed alozovskoy closed 2 years ago
I was looking to apply this pull request but it needs lm-sensors
to be installed otherwise it won't work.
Had to make a change in my dashboard to work (ubuntu 18),
first change, $(type -P sensors 2) .old code was including the /usr/bin/sensor in the json second -f 7 instead of 3 to get the temp value
hope you find it useful
cpu_temp() {
local ID=
[ -f /etc/os-release ] && source /etc/os-release
case "$ID" in
"raspbian")
cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "$((cpu/1000))" | _parseAndPrint
;;
)
if "$(type -P sensors 2)" >/dev/null ; then
returnString=sensors
if [[ "${returnString/"k10"}" != "${returnString}" ]] ; then
$ECHO ${returnString##*k10} | $CUT -d ' ' -f 6 | $CUT -c 2- | $CUT -c 1-4
#intel
elif [[ "${returnString/"core"}" != "${returnString}" ]] ; then
fromcore=${returnString##*"coretemp"}
$ECHO ${fromcore##*Physical} | $CUT -d ' ' **-f 7** | $CUT -c 2-5 | _parseAndPrint
fi
else
$ECHO "[]" | _parseAndPrint
fi
;;
esac }
@Surrealcrow or simply add |"ubuntu"
after "raspbian"
in the switch/case
block.
It has the first advantage to not need to have lm-sensors
to be installed 😉
@Jiab77 i was thinking about that, however after a test i noticed that the reported temp in the raspian option was off by some degrees, I don't really know if it is only my case.
thanks!
Hi, I have same problem on my intel based PC under linux mint 20.04
sensors output was:
coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +32.0°C (high = +100.0°C, crit = +100.0°C)
Core 0: +30.0°C (high = +100.0°C, crit = +100.0°C)
Core 1: +30.0°C (high = +100.0°C, crit = +100.0°C)
Core 2: +31.0°C (high = +100.0°C, crit = +100.0°C)
Core 3: +32.0°C (high = +100.0°C, crit = +100.0°C)
acpitz-acpi-0
Adapter: ACPI interface
temp1: +27.8°C (crit = +105.0°C)
iwlwifi_1-virtual-0
Adapter: Virtual device
temp1: +37.0°C
nvme-pci-0100
Adapter: PCI adapter
Composite: +33.9°C (low = -0.1°C, high = +74.8°C)
(crit = +79.8°C)
so I fixed it like this on my code local copy:
--- a/app/server/linux_json_api.sh
+++ b/app/server/linux_json_api.sh
@@ -92,7 +92,7 @@ cpu_temp() {
echo "$((cpu/1000))" | _parseAndPrint
;;
*)
- if type -P sensors 2>/dev/null; then
+ if "$(type -P sensors 2)">/dev/null; then
returnString=`sensors`
#amd
if [[ "${returnString/"k10"}" != "${returnString}" ]] ; then
@@ -100,7 +100,7 @@ cpu_temp() {
#intel
elif [[ "${returnString/"core"}" != "${returnString}" ]] ; then
fromcore=${returnString##*"coretemp"}
- $ECHO ${fromcore##*Physical} | $CUT -d ' ' -f 3 | $CUT -c 2-5 | _parseAndPrint
+ $ECHO ${fromcore##*Package} | $CUT -d ' ' -f 3 | $CUT -c 2-5 | _parseAndPrint
fi
else
$ECHO "[]" | _parseAndPrint
https://github.com/afaqurk/linux-dash/issues/451 - Getting an average value of CPU cores temperature when sensors not return "Physical" metric.
Unfortunately, i can't check it on real hardware (all my devices return data with "Physical" metric), but it work on "synthetic" tests.