Public bug reported:

Binary package hint: hardinfo

This installation is a 32bits Hardy Heron Alpha 2.

I start the "hardinfo" utility and browse to the Devices -> Sensors
category to check temperature values and status of cooling fans of this
PC.

Unfortunately it does not show correct sensor names. 
It just reports fan1, fan2, fan3... and temp1, temp2, temp3  etc. It's hard to 
tell what sensor is what. 
Study the picture: http://www.edbl.no/tmp/hardinfo-improve-temperature-info.png

I know that lm-sensors (and CLI programs: sensors and sensors-detect) can 
distinguish between the various sensors and give them right names. 
Also GNOMEs "Hardware Sensor Monitor" applet shows correct sensor names.
Study this picture: http://bildr.no/view/134268 (properties of "Hardware Sensor 
Monitor" applet in GNOME, taken from my Hardy Heron installation)
------------

Let's take a look at the Hardinfo's code.
$ apt-get source hardinfo 
$ cd hardinfo*

Open the arch/linux/x86/sensors.h file.
$ gedit arch/linux/x86/sensors.h 

Findings:

1) The read_sensor_labels() function fails to open the /etc/sensors.conf file.
I have a correct installation of lm-sensors. It uses /etc/sensors3.conf not 
/etc/sensors.conf.

/etc/sensors.conf (or /etc/sensors3.conf) is normally generated by the 
sensors-detect program that probes the hardware for chipsets sensors. It writes 
the sensor information to config file and determines the right driver names. 
The driver names are usually written to /etc/modules file.
----

Study the manual of sensors program.
$ man sensors 

FILES
  The system wide configuration file. See sensors.conf(5) for further details
  /etc/sensors3.conf
  /etc/sensors.conf
----

Hardinfo need to check both file names.
The new code will look like this.

static void read_sensor_labels(gchar * driver)
{
    ...

    /* Try to open lm-sensors config file sensors3.conf */ 
    conf = fopen("/etc/sensors3.conf", "r");

    /* If it fails, try to open sensors.conf */ 
    if (!conf) {
        conf = fopen("/etc/sensors.conf", "r");
        return;
    }

    if (!conf) return;

    ...
------------------------------

2) At the bottom of the read_sensor_labels() function. 
   Arguments to the g_str_has_prefix() are wrong way. This is the correct way

    /* Old code: if (g_str_has_prefix(driver, chips[i] + 1))  */ 
    if (g_str_has_prefix(chips[i] + 1, driver)) {
        lock = TRUE;
        break;
    }
    -----------

   driver gets its value from the hwmon listing. There is normally a link to 
the driver name.
   $ ls -l /sys/class/hwmon/hwmon0/device/driver
     lrwxrwxrwx 1 root root 0 2007-12-25 10:54 
/sys/class/hwmon/hwmon0/device/driver 
                                                       ---> 
../../../../bus/i2c/drivers/w83627ehf

    As you can see, in my case, the driver is "w83627ehf" and there is a 
corresponding section in the /etc/sensors3.conf file.
    
    The variable chips[i] has the "chips ...." section name. In my case it is 
"w83627ehf-*". The code removes the ending "*",
    So the code need to be 

    if (g_str_has_prefix(chips[i] + 1, driver)) {
        lock = TRUE;
        break;
    }
------------------------------

3) Hardinfo reports wrong labels for temperature sensors of CPU core 0
and CPU core 1.

This PC has an Intel Dual Core processor (it has 2 cores). 
The following device sensors and information are available.

hwmon0: represents all the fans, temperatures and voltages of the
motherboard, power supply and the CPU generally.

hwmon1: sensor and device information for the CPU core 0.

hwmon2: sensor and device information for the CPU core 1.

Study this directory listing:

$ ls -l /sys/class/hwmon/hwmon?/
/sys/class/hwmon/hwmon0/:
lrwxrwxrwx 1 root root    0 2007-12-25 10:54 device -> 
../../../class/i2c-adapter/i2c-9191/9191-0290
lrwxrwxrwx 1 root root    0 2007-12-25 10:54 subsystem -> ../../../class/hwmon
--w------- 1 root root 4096 2007-12-25 12:59 uevent

/sys/class/hwmon/hwmon1/:
lrwxrwxrwx 1 root root    0 2007-12-25 10:54 device -> 
../../../devices/platform/coretemp.0
lrwxrwxrwx 1 root root    0 2007-12-25 10:54 subsystem -> ../../../class/hwmon
--w------- 1 root root 4096 2007-12-25 13:00 uevent

/sys/class/hwmon/hwmon2/:
lrwxrwxrwx 1 root root    0 2007-12-25 10:54 device -> 
../../../devices/platform/coretemp.1
lrwxrwxrwx 1 root root    0 2007-12-25 10:54 subsystem -> ../../../class/hwmon
--w------- 1 root root 4096 2007-12-25 16:17 uevent


The driver names are 
* w83627ehf (driver to read status of all fans and the CPU fan/temperature 
generally).
Your system may have a different motherboard, chipset and driver. 

* coretemp (temperature sensor of the CPU core 0 ) and 
* coretemp (temperature sensor of the CPU core 1 )

Hardinfo gets the driver names by reading these symbolic links.
 
$ readlink -f /sys/class/hwmon/hwmon0/device/driver 
/sys/bus/i2c/drivers/w83627ehf

$ readlink -f /sys/class/hwmon/hwmon1/device/driver 
/sys/bus/platform/drivers/coretemp

$ readlink -f /sys/class/hwmon/hwmon2/device/driver 
/sys/bus/platform/drivers/coretemp
----------

The read_sensor_labels() function [in the arch/linux/x86/sensors.h file] 
creates a "sensor_labels" hash map.
This hash map is common to all two/three drivers (w83627ehf, coretemp) where it 
stores (key, text label) pairs like
temp1  Sys.temp
temp2  CPU temp
temp3  AUX temp

The problem is that the code does not distinguish between the various drivers.
Both w83627ehf and coretemp sensor's (or driver's) get the same labels for 
temp1 and temp2 etc.

Study this picture: http://www.edbl.no/tmp/hardinfo-temperature-sensor-
labels.jpg

The labels come normally from the /etc/sensors?.conf file, but there are 
exceptions.
In this machine, the /etc/sensors3.conf file has no knowledge of the CPU core 0 
and core 1.
The CPU cores present their own text labels directly in the 
/sys/class/hwmon/hwmon[12]/device/driver/coretemp.*/ directory. 
See

$ ls -l  /sys/class/hwmon/hwmon1/device/
lrwxrwxrwx 1 root root    0 2007-12-25 10:56 bus -> ../../../bus/platform
lrwxrwxrwx 1 root root    0 2007-12-25 10:54 driver -> 
../../../bus/platform/drivers/coretemp
lrwxrwxrwx 1 root root    0 2007-12-25 10:56 hwmon:hwmon1 -> 
../../../class/hwmon/hwmon1
-r--r--r-- 1 root root 4096 2007-12-25 10:56 modalias
-r--r--r-- 1 root root 4096 2007-12-25 10:56 name
drwxr-xr-x 2 root root    0 2007-12-25 10:54 power
lrwxrwxrwx 1 root root    0 2007-12-25 10:54 subsystem -> ../../../bus/platform
-r--r--r-- 1 root root 4096 2007-12-25 10:56 temp1_crit
-r--r--r-- 1 root root 4096 2007-12-25 10:56 temp1_crit_alarm
-r--r--r-- 1 root root 4096 2007-12-25 10:56 temp1_input
-r--r--r-- 1 root root 4096 2007-12-25 10:56 temp1_label  
<----------------------- The label
-rw-r--r-- 1 root root 4096 2007-12-25 10:56 uevent

There is a temp1_label file. Read it.
$ cat /sys/class/hwmon/hwmon1/device/temp1_label
Core0 temp

And for the temperature of the CPU core 2
$ cat  /sys/class/hwmon/hwmon2/device/temp1_label 
Core1 temp

I think these are the correct labels that hardinfo should display.
---------
Additional information:
/etc/sensors3.conf file from this machine:  
http://www.edbl.no/tmp/etc/sensors3.conf

System report generated by hardinfo:
http://www.futuredesktop.org/tmp/hardinfo_report.html

BTW: What an excellent product Hardinfo is.  Many thanks.

** Affects: hardinfo (Ubuntu)
     Importance: Undecided
         Status: New

-- 
Hardinfo: Hardinfo does not show correct labels (names) for all device sensors.
https://bugs.launchpad.net/bugs/178600
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to