Skip to content

Handle thermal_zone errors gracefully #2980

Closed

Description

Host operating system:

Linux 5.10.104-tegra #18 SMP PREEMPT aarch64 aarch64 aarch64 GNU/Linux

node_exporter version:

1.7.0

node_exporter command line flags:

--path.rootfs=/host

node_exporter log output

...
caller=collector.go:169 level=error msg="collector failed" name=thermal_zone duration_seconds=0.01870677 err="read /sys/class/thermal/thermal_zone10/temp: invalid argument"
caller=collector.go:169 level=error msg="collector failed" name=thermal_zone duration_seconds=0.001411717 err="read /sys/class/thermal/thermal_zone10/temp: invalid argument"
...

Are you running node_exporter in Docker?

Yes

What did you do that produced an error?

Running node_exporter in a docker container on a custom embedded device.

What did you expect to see?

Disabled thermal zones as either being ignored or optionally being filtered out.

What did you see instead?

The entire thermal_zone collector fails for all thermal_zones.

When a thermal zone is disabled which can be determined via /sys/class/thermal/thermal_zone10/mode, it would be nice for node_exporter to handle it gracefully whether natively or via flag, or allow specific files/devices be filtered out manually instead of as an entire class of devices.

My temporry workaround has been to use the Pushgateway with a curl container in my docker compose file as so:

  pushgateway:
    image: prom/pushgateway
    container_name: pushgateway
    restart: unless-stopped
    networks:
      - metrics
  curl_thermals:
    image: curlimages/curl
    container_name: curl_thermals
    command: '/bin/sh /pushgateway-thermal-zones.sh'
    pid: host
    restart: unless-stopped
    volumes:
      - /:/host:ro,rslave
      - ./pushgateway-thermal-zones.sh:/pushgateway-thermal-zones.sh:ro,rslave
    networks:
      - metrics

With this pushgateway-thermal-zones.sh script:

while true
do 
    output="# TYPE thermal_zone gauge\n# HELP thermal_zone Thermal zone temperatures in Celsius\n"

    # Loop through each thermal zone directory in /host/sys/class/thermal
    for zone in /host/sys/class/thermal/thermal_zone*; do
        # Check if the thermal zone is enabled by reading the mode file
        mode=$(cat "${zone}/mode")
        if [ "${mode}" = "enabled" ]; then
            zone_number=$(basename ${zone} | sed 's/thermal_zone//')
            zone_type=$(cat "${zone}/type")
            zone_temp=$(cat "${zone}/temp")
            zone_temp_scaled=$(echo "scale=2; ${zone_temp} / 1000.0" | bc)

            # Append the details to the output variable
            output="${output}thermal_zone{zone=\"${zone_number}\", type=\"${zone_type}\"} ${zone_temp_scaled}\n"
        fi
    done

    echo -e $output | curl -s --data-binary @- http://pushgateway:9091/metrics/job/thermal_zones/
    sleep 3
done

Activity

  1. Kylea650 commented on Apr 10, 2024

    @Kylea650

    Seems like the error is coming from here: https://github.com/prometheus/procfs/blob/69fc8f61debb3bd7efca3a9a1c295d4012022830/sysfs/class_thermal.go#L73 / https://github.com/prometheus/procfs/blob/69fc8f61debb3bd7efca3a9a1c295d4012022830/sysfs/class_thermal.go#L52 - maybe there should be a check here if the error is of type os.ErrInvalid and either return an empty ClassThermalZonesStat{} or ignore it. Another option could be to check the mode for ‘disabled’ first in parseClassThermalZone() and return early.

    not sure how to achieve this directly from node_exporter.

  2. discordianfish commented on Apr 15, 2024

    @discordianfish
    Member

    @Kylea650 Checking mode for disabled sounds like a good option. If anyone wants to submit a PR to sysfs feel free to ping me there

  3. Kylea650 commented on Apr 15, 2024

    @Kylea650

    @discordianfish Happy to raise a new issue mentioning this one and PR over in sysfs this week. Cheers!

  4. parthlaw commented on Sep 12, 2024

    @parthlaw

    Is this issue still open?

  5. SuperQ commented on Mar 8, 2026

    @SuperQ
    Member

    Interesting, I can't reproduce this. I have a disabled thermal zone but it still lets me read temp.

    $ uname -a
    Linux mrhat 6.17.0-14-generic #14~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Jan 15 15:52:10 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
    $ for f in /sys/class/thermal/thermal_zone*; do echo "$f: $(< $f/mode) $(< $f/temp)" ; done
    /sys/class/thermal/thermal_zone0: enabled 62000
    /sys/class/thermal/thermal_zone1: disabled 20000
    /sys/class/thermal/thermal_zone2: enabled 47050
    /sys/class/thermal/thermal_zone3: enabled 54050
    /sys/class/thermal/thermal_zone4: enabled 53050
    /sys/class/thermal/thermal_zone5: enabled 49050
    /sys/class/thermal/thermal_zone6: enabled 62050
    /sys/class/thermal/thermal_zone7: enabled 58000
    /sys/class/thermal/thermal_zone8: enabled 36000
    /sys/class/thermal/thermal_zone9: enabled 58000
    

    Maybe this is platform-specific problem?

  6. added a commit that references this issue on Mar 8, 2026
  7. SuperQ commented on Mar 8, 2026

    @SuperQ
    Member

    I decided to try a different refactor, prometheus/procfs#794. This allows us to pass all errors reading from a thermal zone back to the node_exporter.

  8. added a commit that references this issue on Jun 9, 2026
    c1d414e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions