ravenclaw900 / DietPi-Dashboard

A lightweight, standalone web dashboard for DietPi
GNU General Public License v3.0
128 stars 17 forks source link

Temperature reporting does not match #387

Closed KalixtShawxo closed 1 year ago

KalixtShawxo commented 2 years ago

Describe the bug:

The dashboard temperature reports a different temperature than the header displays when opening a terminal window. They are significantly different. The header says it's running hot while the dashboard ask "who pute in the freezer. Version of DietPi-Dashboard: 0.6.1

Nightly or stable: Stable

Version of DietPi: 8.9.2

Device architecture: X86_64 on a Dell E5540 laptop To Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Error log

Additional context

Screenshot_20221009-224331 Screenshot_20221009-224308

MichaIng commented 2 years ago

Many thanks for your report.

Both use different methods to obtain the temperature. The dashboard seems to show one that ia too low, the one from the banner probably too high?

The banner uses sysfs where sadly no generic interface is available but different hardware uses often a different one. The following should show all available sysfs temperature sources:

for i in /sys/class/thermal/thermal_zone[0-9]/temp /sys/class/hwmon/hwmon[0-9]/temp[0-9]_input /sys/devices/platform/coretemp.[0-9]/hwmon/hwmon[0-9]/temp[0-9]_input
do
[[ -e $i ]] && echo "$i : $(<$i)"
done

The coretemp ones are taken with highest priority since they are nearly assured to show the actual CPU core temperatures.

KalixtShawxo commented 2 years ago

Hi, I'm glad to help, here are the results from the script: Screenshot_20221010-055723

MichaIng commented 2 years ago

It looks like the banner is correct and the 25 °C from zone0 never changes, hence are incorrectly taken by the Rust library. We could have look into this library, see how they get the temp and probably propose a fix. If it internally uses the sysfs interface as well, it should be easy to add the coretemp "files" with higher priority.

Is it realistic that the core has 70 °C, i.e. weak or passiv cooling or taken during high load?

KalixtShawxo commented 2 years ago

It's likely running hot, the laptop is running @.*** with the maximum settings, I'll probably add a fan under the laptop for additional cooling.

Sent from Yahoo Mail on Android

On Mon, Oct 10, 2022 at 7:50, @.***> wrote:

It looks like the banner is correct and the 25 °C from zone0 never change, hence are incorrectly taken by the Rust library. We could have look into this library, see how they get the temp and probably propose a fix. If it internally uses the sysfs interface as well, it should be easy to add the coretemp "files" with higher priority.

Is it realistic that the core has 70 °C, i.e. weak or passiv cooling or taken during high load?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ravenclaw900 commented 2 years ago

Yes, rust-psutil uses sysfs internally to get temperatures (https://github.com/rust-psutil/rust-psutil/blob/master/src/sensors/sys/linux/temperatures.rs). It first tries to get data from hwmon, then thermal_zone, and returns a list of sensors. The dashboard currently just uses the first item in that list. It doesn't seem to use coretemp internally at all, though that seems like an easy change.

KalixtShawxo commented 2 years ago

This is the first time I've seen such a disparity of the two readings ... I have used Dietpi dashboard on beaglebones, raspis, odroids, pines, and whatnot.... This was the first time putting it onto a laptop replacing windows. 

Sent from Yahoo Mail on Android

On Mon, Oct 10, 2022 at 9:59, @.***> wrote:

Yes, rust-psutil uses sysfs internally to get temperatures (https://github.com/rust-psutil/rust-psutil/blob/master/src/sensors/sys/linux/temperatures.rs). It first tries to get data from hwmon, then thermal_zone, and returns a list of sensors. The dashboard currently just uses the first item in that list. It doesn't seem to use coretemp internally at all, though that seems like an easy change.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

MichaIng commented 2 years ago

So far I've seen the coretemp interface being available on x86 systems only, not on SBCs.

Hmm, rust-psutil returns unit, label, current, max, crit. We need to see if coretemp contains these values as well. Otherwise, probably we can implement reading coretemp ourselves (with temp only) if available and use the lib as fallback only.

KalixtShawxo commented 2 years ago

I'm happy to help if I can, run any scripts or whatever.I am goin to try to cool it down a bit with a laptop cooling fan that goes under it. 

Sent from Yahoo Mail on Android

On Mon, Oct 10, 2022 at 11:37, @.***> wrote:

So far I've seen the coretemp interface being available on x86 systems only, not on SBCs.

Hmm, rust-psutil returns unit, label, current, max, crit. We need to see if coretemp contains these values as well. Otherwise, probably we can implement reading coretemp ourselves (with temp only) if available and use the lib as fallback only.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ravenclaw900 commented 2 years ago

Forked and tested on x86: https://github.com/ravenclaw900/rust-psutil/tree/coretemp. It tries to use coretemp, but falls back to hwmon and thermal_zone if it isn't available. coretemp actually seems to provide the exact same information as hwmon, so I just used the existing functions in the library.

MichaIng commented 2 years ago

You are right, so basically coretemp seems to be a wrapper for hwmon but containing the actual CPU sensors only. This makes implementation much easier, reusing the hwmon_sensor() function that already exists, as you did. Great work!

KalixtShawxo commented 2 years ago

So I put the fan under the laptop,the banner temp reading is starting to drop while the dashboard temp is staying at 25*. Looks like for whatever reason it's just stuck? 

Sent from Yahoo Mail on Android

On Mon, Oct 10, 2022 at 14:07, @.***> wrote:

You are right, so basically coretemp seems to be a wrapper for hwmon but containing the actual CPU temperatures only. This makes implementation much easier, reusing the hwmon_sensor() function the already exists, as you did. Great work!

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

MichaIng commented 2 years ago

This is what I thought, 25 °C at all time, for whatever reason it is like that 😄. @ravenclaw900 do you want to open a PR? The only thing that might be additionally required is to apply the CentOS workaround with additional device directory as well:

fn coretemp() -> Vec<Result<TemperatureSensor>> {
    let mut glob_results = glob("/sys/devices/platform/coretemp.*/hwmon/hwmon*/temp*_input");

    if glob_results.is_empty() {
        // CentOS has an intermediate `device` directory:
        // https://github.com/giampaolo/psutil/issues/971
        // https://github.com/nicolargo/glances/issues/1060
        glob_results = glob("/sys/devices/platform/coretemp.*/hwmon/hwmon*/device/temp*_input");
    }

    glob_results
        .into_iter()
        .map(|result| match result {
            Ok(path) => hwmon_sensor(path),
            Err(e) => Err(e),
        })
        .collect()
}

Probably the same function can be used once with /sys/devices/platform/coretemp.* and once with /sys/class path prefix to reduce doubled code 🤔.

ravenclaw900 commented 2 years ago

@KalixtShawxo, if you'd like, you can try the patched version at https://nightly.link/ravenclaw900/DietPi-Dashboard/actions/runs/3220939989/dietpi-dashboard-x86_64.zip before I open the PR. @MichaIng, let me quickly spin up a CentOS VM to make sure that's required, and I'll combine the functions if so.

KalixtShawxo commented 2 years ago

Sure, that sounds good. I need a break from the other thing I'm working on.  I'll see if I can get the nightly in and report if it changes the readings.  I'm not entirely sure the banner one is right,I've had the fan (about 8 inches in size) under the laptop for awhile now it's only down to 67* C. 

Sent from Yahoo Mail on Android

On Mon, Oct 10, 2022 at 15:40, @.***> wrote:

@KalixtShawxo, if you'd like, you can try the patched version at https://nightly.link/ravenclaw900/DietPi-Dashboard/actions/runs/3220939989/dietpi-dashboard-x86_64.zip before I open the PR. @MichaIng, let me quickly spin up a CentOS container to make sure that's required, and I'll combine the functions if so.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

ravenclaw900 commented 2 years ago

@MichaIng, one thing before the PR: coretemp only measures temperature of the CPU cores (and only on Intel), and its data can also be found in hwmon. The temperatures function is meant to give data on every sensor that it can, not just CPU. I think that it would be better to just try and search for a sensor named coretemp in the dashboard, and fallback to reading the first one otherwise.

MichaIng commented 2 years ago

Ah right, it does not return the first match but info on all matches.

Okay then it makes more sense to add it to the dashboard and use rust-psutil as fallback.

ravenclaw900 commented 2 years ago

coretemp is already included in hwmon, so I'd just have to search for it. For instance, in the screenshot, coretemp and hwmon4 are the same.

MichaIng commented 2 years ago

Those will be just symlinks created by the kernel/driver with Intel CPU.

KalixtShawxo commented 2 years ago

Hi, sorry for late response. I got distracted be another issue. Anyway, I d/l the nightly and installed it and now the dashboard is reporting temps the same as the banner. Says it's running hot, but it's a laptop so I'm not overly worried as If it was a Pi. But nice to now see accurate readings.

MichaIng commented 2 years ago

That is great, thanks for the feedback 🙂.

lmerega commented 1 year ago

Hallo, on my Dell Wyse 3040 the temp is 0 celsius even if in the MOTD it is perfectly shown. Any idea?

Thx

Luca

ravenclaw900 commented 1 year ago

Sorry, since @KalixtShawxo said that their issue was resolved, I haven't yet implemented the proposed fix. Sadly, since my last post, I've actually upgraded my computer, and it runs on an AMD CPU now, so I can't test the fix anymore. If you wouldn't mind testing the binary at https://nightly.link/ravenclaw900/DietPi-Dashboard/actions/runs/3798150466/dietpi-dashboard-x86_64.zip, and if that fixes your problem, I'll merge the fix into nightly.

lmerega commented 1 year ago

Hi, I installed the fix and it works. Here it is on my Atom CPU. image

Waiting 4 the release :-)

Thx

surtarso commented 1 year ago

Hi there, ended up here trying to fix the same issue as @lmerega... My processor is an AMD fx-8300, diepi-banner shows temperature correctly, the dashboard shows 0 (zero). Is the fix you mentioned coming next update? Or should I keep tinkering? =) thx.

ravenclaw900 commented 1 year ago

Hi, The fix right now will be coming next update, however it is specifically for Intel CPUs, so it might not do anything for yours. However, feel free to test the nightly and let us know if it fixes your problem.

churchofnoise commented 1 year ago

Just installed dietpi-dashboard on an Intel NUC8i3BEH (in an Akasa Turing X8 passive case) and get the following temp reading: -263ºC/-442ºF: Who put me in the freezer! I can confirm we're definitely not nearing 0 Kelvin in here :)

ravenclaw900 commented 1 year ago

Have you tried the nightly? The last release was only a security hotfix, so the temperature fix is only on the nightly.

churchofnoise commented 1 year ago

Aha! This was on stable indeed, will try nightly.