hjelev / rpi-mqtt-monitor

Raspberry Pi MQTT Monitor gathers system information and sends it to a MQTT server.
GNU General Public License v3.0
189 stars 43 forks source link

Add thermal zone type support for x86 CPU (Intel) #149

Closed viliks closed 1 month ago

viliks commented 1 month ago

Hi,

I'm using this fantactic script on Intel N100 CPU (with Debian Bookworm) and have an issue with temperature. Temperature check script hangs - does not even return 0 value from try/catch block. HA sensor value is "Unknown". CPU temperature is reported in thermal zone type x86_pkg_temp. Changing the check to grep -iqE \"cpu|x86_pkg_temp\" and everything is perfect again.

Or may be make thermal zone type configurable.

Thanks.

hjelev commented 1 month ago

Hi, which version of the script do you use? I have recently updated the cpu_temp bash command. Is this what you see in your code?

"awk '{printf (\"%.2f\\n\", $1/1000); }' $(for zone in /sys/class/thermal/thermal_zone*/; do grep -iq \"cpu\" \"${zone}type\" && echo \"${zone}temp\"; done)"

If its this maybe its hanging on some of the zones as its checking them all. If this is the case a configurable thermal zone is the solution.

I am running the script on a similar cpu - pentium silver j504 - and it works fine.

Pls also show me the output of this command:

for zone in /sys/class/thermal/thermal_zone*/; do
  echo "Thermal Zone: $zone"
  cat "${zone}type"
  cat "${zone}temp"
  echo ""
done
viliks commented 1 month ago

Hi, script version 0.9.9

try to change "cpu" to something that does not exist and run rpi-mqtt-monitor -d. script hangs and this is result after Ctrl+C

^CTraceback (most recent call last):
  File "/home/viliks/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 866, in <module>
    gather_and_send_info()
  File "/home/viliks/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 759, in gather_and_send_info
    cpu_load, cpu_temp, used_space, voltage, sys_clock_speed, swap, memory, uptime_days, uptime_seconds, wifi_signal, wifi_signal_dbm, rpi5_fan_speed, drive_temps, rpi_power_status = collect_monitored_values()
                                                                                                                                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/viliks/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 728, in collect_monitored_values
    cpu_temp = check_cpu_temp()
               ^^^^^^^^^^^^^^^^
  File "/home/viliks/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 113, in check_cpu_temp
    p = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE).communicate()[0]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1194, in communicate
    stdout = self.stdout.read()
             ^^^^^^^^^^^^^^^^^^

result is same with version 0.10.0 and with the proposed change rpi-mqtt-monitor -d displays:

:: rpi-mqtt-monitor
   Version: 0.10.0

:: Device Information
   Model Name:  Intel(R) N100
   Manufacturer:  GenuineIntel
   OS: Debian GNU/Linux 12 (bookworm)
   Hostname: -----edited
   IP Address: ------edited
   MAC Address: ------edited
   Update Check Interval: 3600 seconds

:: Measured values
   CPU Load: 42.5 %
   CPU Temp: 52.00 °C
   Used Space: 6 %
   Voltage: False V
   CPU Clock Speed: False MHz
   Swap: False %
   Memory: 14 %
   Uptime: 0 days
   Wifi Signal: False %
   Wifi Signal dBm: False
   RPI5 Fan Speed: False RPM
   RPI Power Status: False
   Update: {"installed_ver": "0.10.0", "new_ver": "0.10.0"}
   Nvme Temp: 34.85°C

Output listing thermal zones:

Thermal Zone: /sys/class/thermal/thermal_zone0/
acpitz
27800
Thermal Zone: /sys/class/thermal/thermal_zone1/
x86_pkg_temp
48000

I also run it on OrangePi without problems, because:

Thermal Zone: /sys/class/thermal/thermal_zone0/
cpu_thermal
30870
hjelev commented 1 month ago

I have made the cpu thermal zone configurable in 0.10.1.

viliks commented 1 month ago

Perfect, thank you very much.