psutil icon indicating copy to clipboard operation
psutil copied to clipboard

Added device address in temperature sensors dict

Open a13ssandr0 opened this issue 1 year ago • 0 comments

Summary

  • OS: KUbuntu 23.04
  • Bug fix: yes
  • Type: core
  • Fixes: Added device address in temperature sensors dict

Description

Some systems, like mine, may have multiple temperature devices, like two nvme SSDs, both under the same name, in my case 'nvme'. lm-sensors solves this problem adding, at the end of the device name, interface name, root bridge number (bus number) and device number. I solved the problem getting the address from /sys/class/hwmon/hwmonX/device/address when present, it existed for my two SSDs and on another PC with only one nvme SSD, so I think every PCIe device with sensors (discovered by the system) will have this file.

psutil.sensors_temperatures() before this fix:

{'nvme': [shwtemp(label='Composite', current=46.85, high=84.85, critical=84.85),
          shwtemp(label='Sensor 1', current=46.85, high=65261.85, critical=65261.85),
          shwtemp(label='Sensor 2', current=47.85, high=65261.85, critical=65261.85),
          shwtemp(label='Composite', current=39.85, high=81.85, critical=84.85),
          shwtemp(label='Sensor 1', current=39.85, high=65261.85, critical=65261.85),
          shwtemp(label='Sensor 2', current=42.85, high=65261.85, critical=65261.85)],
 'coretemp': [shwtemp(label='Package id 0', current=36.0, high=88.0, critical=98.0),
              shwtemp(label='Core 12', current=35.0, high=88.0, critical=98.0),
              shwtemp(label='Core 13', current=34.0, high=88.0, critical=98.0),
              shwtemp(label='Core 0', current=36.0, high=88.0, critical=98.0),
              shwtemp(label='Core 1', current=34.0, high=88.0, critical=98.0),
              shwtemp(label='Core 2', current=36.0, high=88.0, critical=98.0),
              shwtemp(label='Core 3', current=34.0, high=88.0, critical=98.0),
              shwtemp(label='Core 5', current=35.0, high=88.0, critical=98.0),
              shwtemp(label='Core 6', current=35.0, high=88.0, critical=98.0),
              shwtemp(label='Core 10', current=35.0, high=88.0, critical=98.0),
              shwtemp(label='Core 11', current=36.0, high=88.0, critical=98.0)],
 'nct6798': [shwtemp(label='SYSTIN', current=35.0, high=80.0, critical=80.0),
             shwtemp(label='PCH_CPU_TEMP', current=0.0, high=None, critical=None),
             shwtemp(label='CPUTIN', current=40.0, high=80.0, critical=80.0),
             shwtemp(label='AUXTIN0', current=50.5, high=None, critical=None),
             shwtemp(label='AUXTIN1', current=16.0, high=None, critical=None),
             shwtemp(label='AUXTIN2', current=25.0, high=None, critical=None),
             shwtemp(label='AUXTIN3', current=64.0, high=None, critical=None),
             shwtemp(label='PECI Agent 0 Calibration', current=40.0, high=None, critical=None),
             shwtemp(label='PCH_CHIP_CPU_MAX_TEMP', current=0.0, high=None, critical=None),
             shwtemp(label='PCH_CHIP_TEMP', current=0.0, high=None, critical=None)]}

psutil.sensors_temperatures() after this fix:

{'nvme-b400': [shwtemp(label='Composite', current=46.85, high=84.85, critical=84.85),
               shwtemp(label='Sensor 1', current=46.85, high=65261.85, critical=65261.85),
               shwtemp(label='Sensor 2', current=47.85, high=65261.85, critical=65261.85)],
 'nvme-b300': [shwtemp(label='Composite', current=39.85, high=81.85, critical=84.85),
               shwtemp(label='Sensor 1', current=39.85, high=65261.85, critical=65261.85),
               shwtemp(label='Sensor 2', current=42.85, high=65261.85, critical=65261.85)],
 'coretemp': [shwtemp(label='Package id 0', current=36.0, high=88.0, critical=98.0),
              shwtemp(label='Core 12', current=35.0, high=88.0, critical=98.0),
              shwtemp(label='Core 13', current=35.0, high=88.0, critical=98.0),
              shwtemp(label='Core 0', current=36.0, high=88.0, critical=98.0),
              shwtemp(label='Core 1', current=34.0, high=88.0, critical=98.0),
              shwtemp(label='Core 2', current=36.0, high=88.0, critical=98.0),
              shwtemp(label='Core 3', current=34.0, high=88.0, critical=98.0),
              shwtemp(label='Core 5', current=35.0, high=88.0, critical=98.0),
              shwtemp(label='Core 6', current=35.0, high=88.0, critical=98.0),
              shwtemp(label='Core 10', current=35.0, high=88.0, critical=98.0),
              shwtemp(label='Core 11', current=36.0, high=88.0, critical=98.0)],
 'nct6798': [shwtemp(label='SYSTIN', current=35.0, high=80.0, critical=80.0),
             shwtemp(label='PCH_CPU_TEMP', current=0.0, high=None, critical=None),
             shwtemp(label='CPUTIN', current=40.0, high=80.0, critical=80.0),
             shwtemp(label='AUXTIN0', current=50.5, high=None, critical=None),
             shwtemp(label='AUXTIN1', current=16.0, high=None, critical=None),
             shwtemp(label='AUXTIN2', current=25.0, high=None, critical=None),
             shwtemp(label='AUXTIN3', current=64.0, high=None, critical=None),
             shwtemp(label='PECI Agent 0 Calibration', current=40.0, high=None, critical=None),
             shwtemp(label='PCH_CHIP_CPU_MAX_TEMP', current=0.0, high=None, critical=None),
             shwtemp(label='PCH_CHIP_TEMP', current=0.0, high=None, critical=None)]}

a13ssandr0 avatar Sep 10 '23 18:09 a13ssandr0