Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All temperature sensors fail if one rises an error #11

Open
dflvunoooooo opened this issue Jul 18, 2023 · 1 comment
Open

All temperature sensors fail if one rises an error #11

dflvunoooooo opened this issue Jul 18, 2023 · 1 comment

Comments

@dflvunoooooo
Copy link

dflvunoooooo commented Jul 18, 2023

All temp sensors are unavailable, if one of them returns an error.

In my case /sys/class/thermal/thermal_zone0/temp returns /sys/class/thermal/thermal_zone0/temp: No data available this leads to x86 and iwilwfi being unavailable. I changed mainboard and cpu and now do have a wifi card installed, but it is disabled in bios, but it still shows up as zone0 but with no data.

Edit: Edited the post. I confused zone 1 and 0.

@MartinJohannesNilsen
Copy link

I had a problem where the script would not be able to parse temperatures if one of the sensors were unavailable, instead getting an awk error. I solved by editing the temperature function to this:

temperature() {
    # Check if any thermal zones are available
    if ! ls /sys/class/thermal/thermal_zone* > /dev/null 2>&1; then
        return 1
    fi

    sep=""
    for tz in /sys/class/thermal/thermal_zone*; do
        # Verify the type file exists and is readable
        if [[ -r "$tz/type" && -r "$tz/temp" ]]; then
            sensor_name="temperature_$(sed 's/-/_/' < "$tz/type")_C"
            # Check if awk can read the temp file correctly
            temp=$(awk '{printf "%.2f", $1 / 1000}' "$tz/temp" 2>/dev/null)
            if [[ $? -ne 0 ]]; then
                # If awk fails, skip to the next iteration
                continue
            fi

            echo -n "$sep"
            sep=","
            # Only print if awk was successful
            print_key_vals "$sensor_name" "$temp"
        fi
    done
}

This might help you as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants