On Mon, 6 Oct 2025, Van Ly wrote:

sysutils/btop cpu temperature reading doesn't refresh down, the reading went up 
to 89degC while building chromium and hasn't changed.


Hmm. This looks like a btop bug. It only looks at the first sensor (and, that
too not very well), and doesn't match the core temps to the CPUs.

And, on my HW, `acpitz0' is always at 27.800 C even on Linux. Can you try this
patch:

```
diff -urN btop-1.4.5.orig/src/netbsd/btop_collect.cpp 
btop-1.4.5/src/netbsd/btop_collect.cpp
--- btop-1.4.5.orig/src/netbsd/btop_collect.cpp 2025-09-19 20:29:22.000000000 
+0000
+++ btop-1.4.5/src/netbsd/btop_collect.cpp      2025-10-09 00:03:45.503572033 
+0000
@@ -52,6 +52,7 @@
 #include <kvm.h>
 #include <paths.h>
 #include <fcntl.h>
+#include <regex.h>
 #include <unistd.h>
 #include <uvm/uvm_extern.h>

@@ -220,10 +221,10 @@
                prop_object_t fields_array;
                // List of common thermal sensors in NetBSD.
                const string sensors[6] = {
-                       "acpitz0",
-                       "acpitz1",
                        "coretemp0",
                        "coretemp1",
+                       "acpitz0",
+                       "acpitz1",
                        "thinkpad0",
                        "amdzentemp0"
                };
@@ -319,6 +320,12 @@
                        return;
                }

+               regex_t r;
+               if (regcomp(&r, "(cpu[0-9]* )*temperature", REG_EXTENDED)) {
+                       Logger::warning("regcomp() failed");
+                       return;
+               }
+
                string prop_description = "no description";
                while ((fields = (prop_dictionary_t) 
prop_object_iterator_next(prop_object_iterator_t(fields_iter))) != NULL) {
                        props = (prop_dictionary_t) prop_dictionary_get(fields, 
"device-properties");
@@ -335,13 +342,15 @@

                        prop_description = 
prop_string_cstring(prop_string_t(description));

-                       if (prop_description == "temperature") {
+                       // if (prop_description == "temperature") {
+                       if (regexec(&r, prop_description.c_str(), 0, NULL, 0) 
== 0) {
                                current_temp = 
prop_number_integer_value(prop_number_t(cur_value));
                                if (max_value != NULL) {
                                        current_cpu.temp_max = 
MUKTOC(prop_number_integer_value(prop_number_t(max_value)));
                                }
                        }
                }
+               regfree(&r);

                prop_object_iterator_release(fields_iter);
                prop_object_release(dict);
```

It sort-of works for me, even though it's not fully correct (uses `coretemp0'
values for _all_ CPUs).

-RVP

Reply via email to