Add sensors config tool
v3 cover Add sensors config tool
Hi Hans,
At last here is a new version of the sensors config tool.
Now we have a shell script doing the auto installation stuff. See install.sh patch 2/2. Further I removed this part of the python script.
As discussed, the config files from lm-sensors.org are fetched to vendor specific directories and links are made in the root config directory.
This looks like this:
drwxr-xr-x 2 andre andre 4096 2010-03-31 21:01 Abit
lrwxrwxrwx 1 andre andre 16 2010-03-31 21:01 Abit_AA8-DuraMAX ->Abit/AA8-DuraMAX
lrwxrwxrwx 1 andre andre 12 2010-03-31 21:01 Abit_AI7_1.0 ->Abit/AI7-1.0
lrwxrwxrwx 1 andre andre 8 2010-03-31 21:01 Abit_AN7 -> Abit/AN7
drwxr-xr-x 2 andre andre 4096 2010-03-31 21:01 ASRock
lrwxrwxrwx 1 andre andre 17 2010-03-31 21:01 ASRock_M2NF3-VSTA ->ASRock/M2NF3-VSTA
drwxr-xr-x 2 andre andre 4096 2010-03-31 21:01 Fujitsu
lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D23122A ->Fujitsu/D2312A1 lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D2312A1 ->Fujitsu/D2312A1 lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D2312C1 ->Fujitsu/D2312A1 lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D2312C2 ->Fujitsu/D2312A1 lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D2312D2_2.0 ->Fujitsu/D2312A1 lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D2314A1 ->Fujitsu/D2314A1 lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D2314A2 ->Fujitsu/D2314A1
The fetching tool parses headers like:
# board_vendor: Fujitsu
# board_name: D2312A1
# board_version: 1.0
Board version is optional. The block can appear mutliple times.
# board_vendor: Fujitsu
# board_name: D2312A1
# board_vendor: Fujitsu
# board_name: D23122A
# board_vendor: Fujitsu
# board_name: D2312C1
# board_vendor: Fujitsu
# board_name: D2312C2
The same rules apply to the product headers.
# sys_vendor: Fujitsu
# product_name: D2312D2
# product_version: 2.0
Next task is the module auto loading stuff but first, what about this here?
Regards,
Andre
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Andre,
Quoted 4 lines · Andre Prendel
Hi Hans,
At last here is a new version of the sensors config tool.
First of all many thanks for your continued work on this, it is looking very good, so hopefully we will be able to soon ship an lm_sensors with working auto-configuration of (known) motherboards.
Quoted 4 lines
Now we have a shell script doing the auto installation stuff. See
install.shpatch 2/2. Further I removed this part of the python script.
The shell script looks good, nice and simple, great!
Quoted 3 lines
As discussed, the config files from lm-sensors.org are fetched to vendor specific directories and links are made in the root config directory.
Great!
Quoted 10 lines
This looks like this:
drwxr-xr-x 2 andre andre 4096 2010-03-31 21:01 Abit
lrwxrwxrwx 1 andre andre 16 2010-03-31 21:01 Abit_AA8-DuraMAX ->Abit/AA8-DuraMAX
lrwxrwxrwx 1 andre andre 12 2010-03-31 21:01 Abit_AI7_1.0 ->Abit/AI7-1.0
lrwxrwxrwx 1 andre andre 8 2010-03-31 21:01Abit_AN7-> Abit/AN7
drwxr-xr-x 2 andre andre 4096 2010-03-31 21:01 ASRock
lrwxrwxrwx 1 andre andre 17 2010-03-31 21:01 ASRock_M2NF3-VSTA ->ASRock/M2NF3-VSTA
drwxr-xr-x 2 andre andre 4096 2010-03-31 21:01 Fujitsu
Quoted 8 lines
lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D23122A ->Fujitsu/D2312A1 lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D2312A1 ->Fujitsu/D2312A1 lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D2312C1 ->Fujitsu/D2312A1 lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D2312C2 ->Fujitsu/D2312A1 lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D2312D2_2.0 ->Fujitsu/D2312A1 lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D2314A1 ->Fujitsu/D2314A1 lrwxrwxrwx 1 andre andre 15 2010-03-31 21:01 Fujitsu_D2314A2 ->Fujitsu/D2314A1
Also looks good :)
Quoted 20 lines
The fetching tool parses headers like:
#
board_vendor: Fujitsu
#board_name: D2312A1
#board_version: 1.0Board version is optional. The block can appear mutliple times.
#
board_vendor: Fujitsu
#board_name: D2312A1#
board_vendor: Fujitsu
#board_name: D23122A#
board_vendor: Fujitsu
#board_name: D2312C1#
board_vendor: Fujitsu
#board_name: D2312C2
Quoted 9 lines
The same rules apply to the product headers.
#
sys_vendor: Fujitsu
#product_name: D2312D2
#product_version: 2.0Next task is the module auto loading stuff but first, what about this here?
I think this all looks very good! I think the module auto loading is the only remaining item to do before this could actually become production ready (although we will want Jean's input on this too).
The module autoloading requires 2 questions to be answered:
1) How do we store which modules are needed into the configuration files on the wiki
2) How / where / what will these modules get loaded ? Currently we have lines like these in /etc/sysconfig/lm_sensors:
# The format of this file is a shell script that simply defines variables:
# HWMON_MODULES for hardware monitoring driver modules, and optionally # BUS_MODULES for any required bus driver module (for example for I2C or SPI).
HWMON_MODULES="it87"
# For compatibility reasons, modules are also listed individually as variables
# MODULE_0, MODULE_1, MODULE_2, etc.
# You should use BUS_MODULES and HWMON_MODULES instead if possible.
MODULE_0=it87
We could add new "keys" to this file, say:AUTOMOBO_HWMON_MODULESAUTOMOBO_BUS_MODULES
And modify the lm_sensors initscript to recognize these too, or thinking more about this, as we need the script which does the copying of the config file to /etc/sensors.d/automobo.conf, to extract the modules for us anyways (to insert them into /etc/sysconfig/lm_sensors for example). We might just as well make that script load the modules directly.
This also solves a problem with the HWMON_MODULES="it87" syntax, namely that it does not allow specifying module parameters.
Jean, could we have your input on this ?
Thanks & Regards,
Hans
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 47 lines · Hans de Goede
Hi Andre,
Quoted 8 lines · Andre Prendel
Hi Hans,
At last here is a new version of the sensors config tool.
Next task is the module auto loading stuff but first, what about this here?
I think this all looks very good! I think the module auto loading is the only remaining item to do before this could actually become production ready (although we will want Jean's input on this too).
The module autoloading requires 2 questions to be answered:
1) How do we store which modules are needed into the configuration files on the wiki
2) How / where / what will these modules get loaded ? Currently we have lines like these in
/etc/sysconfig/lm_sensors:# The format of this file is a shell script that simply defines variables:
#HWMON_MODULESfor hardware monitoring driver modules, and optionally #BUS_MODULESfor any required bus driver module (for example for I2C or SPI).HWMON_MODULES="it87"
# For compatibility reasons, modules are also listed individually as variables
#MODULE_0,MODULE_1,MODULE_2, etc.
# You should useBUS_MODULESandHWMON_MODULESinstead if possible.MODULE_0=it87
We could add new "keys" to this file, say:
AUTOMOBO_HWMON_MODULESAUTOMOBO_BUS_MODULESAnd modify the
lm_sensorsinitscript to recognize these too, or thinking more about this, as we need the script which does the copying of the config file to/etc/sensors.d/automobo.conf, to extract the modules for us anyways (to insert them into/etc/sysconfig/lm_sensorsfor example). We might just as well make that script load the modules directly.
Quoted 4 lines
This also solves a problem with the HWMON_MODULES="it87" syntax, namely that it does not allow specifying module parameters.
Jean, could we have your input on this ?
No reply from Jean so far. So I'd like to make a proposal.
I'd suggest using the install.sh script (which installs the automobo.conf) to load the driver. The config file gets a "modules" tag specifying the module name. E.g.
# board_name: foo
# board_vendor: bar
# modules: tmp421
Sed gives us the module name and modprobe loads the module. I've extended the install.sh script to do this. See the patch below (load_driver function).
What do you think about this approach?
Thanks,
Andre
---
Index: sensors/prog/detect/install.sh
=================================--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ sensors/prog/detect/install.sh 2010-04-10 23:37:38.510513143 +0200
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+SYSFS_PATH=/sys/class/dmi/id
+CONF_PATH=/var/lib/sensors/conf +INSTALL_FILE=/etc/sensors.d/automobo.conf
+
+BOARD_VENDOR=cat $SYSFS_PATH/board_vendor
+BOARD_NAME=cat $SYSFS_PATH/board_name
+BOARD_VERSION=cat $SYSFS_PATH/board_version
+SYS_VENDOR=cat $SYSFS_PATH/sys_vendor
+PRODUCT_NAME=cat $SYSFS_PATH/product_name
+PRODUCT_VERSION=cat $SYSFS_PATH/product_version
+
+# only for testing
+#BOARD_VENDOR=Fujitsu
+#BOARD_NAMEÒ312C1
+#BOARD_VERSION=1.0
+#SYS_VENDOR=Fujitsu
+#PRODUCT_NAMEÒ312D2
+#PRODUCT_VERSION=2.0
+ +SEARCH_BOARD_VERSION=$CONF_PATH"/"$BOARD_VENDOR"_"$BOARD_NAME"_"$BOARD_VERSION +SEARCH_BOARD=$CONF_PATH"/"$BOARD_VENDOR"_"$BOARD_NAME +SEARCH_SYS_VERSION=$CONF_PATH"/"$SYS_VENDOR"_"$PRODUCT_NAME"_"$PRODUCT_VERSION +SEARCH_SYS=$CONF_PATH"/"$SYS_VENDOR"_"$PRODUCT_NAME
+
+load_driver()
+{
+ MODULES=`sed -n -e 's/^# modules: \([A-Za-z0-9= ]*\).*$/\1/p' $INSTALL_FILE` + echo "Loading driver: $MODULES" + modprobe $MODULES
+}
+
+echo "Looking for config: $SEARCH_BOARD_VERSION"
+if [ -h "$SEARCH_BOARD_VERSION" ]; then
+ echo "Found suitable config" + cp -f $SEARCH_BOARD_VERSION $INSTALL_FILE + load_driver + exit 0
+fi
+
+echo "Looking for config: $SEARCH_BOARD"
+if [ -h "$SEARCH_BOARD" ]; then
+ echo "Found suitable config" + cp -f $SEARCH_BOARD $INSTALL_FILE + load_driver + exit 0
+fi
+
+echo "Looking for config: $SEARCH_SYS_VERSION"
+if [ -h "$SEARCH_SYS_VERSION" ]; then
+ echo "Found suitable config" + cp -f $SEARCH_SYS_VERSION $INSTALL_FILE + load_driver + exit 0
+fi
+
+echo "Looking for config: $SEARCH_SYS"
+if [ -h "$SEARCH_SYS" ]; then
+ echo "Found suitable config" + cp -f $SEARCH_SYS $INSTALL_FILE + load_driver + exit 0
+fi
+
+echo "Could not find a suitable config"
+rm -f $INSTALL_FILE
+
+exit 1
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 36 lines · Andre Prendel
Quoted 35 lines · Hans de Goede
I think this all looks very good! I think the module auto loading is the only remaining item to do before this could actually become production ready (although we will want Jean's input on this too).
The module autoloading requires 2 questions to be answered:
1) How do we store which modules are needed into the configuration files on the wiki
2) How / where / what will these modules get loaded ? Currently we have lines like these in
/etc/sysconfig/lm_sensors:# The format of this file is a shell script that simply defines variables:
#HWMON_MODULESfor hardware monitoring driver modules, and optionally #BUS_MODULESfor any required bus driver module (for example for I2C or SPI).HWMON_MODULES="it87"
# For compatibility reasons, modules are also listed individually as variables
#MODULE_0,MODULE_1,MODULE_2, etc.
# You should useBUS_MODULESandHWMON_MODULESinstead if possible.MODULE_0=it87
We could add new "keys" to this file, say:
AUTOMOBO_HWMON_MODULESAUTOMOBO_BUS_MODULESAnd modify the
lm_sensorsinitscript to recognize these too, or thinking more about this, as we need the script which does the copying of the config file to/etc/sensors.d/automobo.conf, to extract the modules for us anyways (to insert them into/etc/sysconfig/lm_sensorsfor example). We might just as well make that script load the modules directly.
Quoted 4 lines
Quoted 4 lines
This also solves a problem with the HWMON_MODULES="it87" syntax, namely that it does not allow specifying module parameters.
Jean, could we have your input on this ?
If modules need parameters, these should go
to /etc/modprobe.d/hwmon.conf or some such. /etc/sysconfig/lm_sensors isn't the right place for them, because you want the options to be applied even when the modules are loaded manually.
Not that this should be a big concern anyway, as module parameters should almost never be used at this point. sensors-detect no longer generates any for kernels >= 2.6.28.
Quoted 1 line
No reply from Jean so far. So I'd like to make a proposal.
I'm very sorry, but I simply don't have the time to look into your code and proposals right now. Please don't let this stop you, just go ahead with what you have, we have been in need of this feature for years, so the sooner we have it, the better. If it needs adjustments, we can apply them later. I have no doubt that we will discover new needs as users start using your code anyway.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi,
Quoted 62 lines · Andre Prendel
Quoted 47 lines · Hans de Goede
Hi Andre,
Quoted 8 lines · Andre Prendel
Hi Hans,
At last here is a new version of the sensors config tool.
Next task is the module auto loading stuff but first, what about this here?
I think this all looks very good! I think the module auto loading is the only remaining item to do before this could actually become production ready (although we will want Jean's input on this too).
The module autoloading requires 2 questions to be answered:
1) How do we store which modules are needed into the configuration files on the wiki
2) How / where / what will these modules get loaded ? Currently we have lines like these in
/etc/sysconfig/lm_sensors:# The format of this file is a shell script that simply defines variables:
#HWMON_MODULESfor hardware monitoring driver modules, and optionally #BUS_MODULESfor any required bus driver module (for example for I2C or SPI).HWMON_MODULES="it87"
# For compatibility reasons, modules are also listed individually as variables
#MODULE_0,MODULE_1,MODULE_2, etc.
# You should useBUS_MODULESandHWMON_MODULESinstead if possible.MODULE_0=it87
We could add new "keys" to this file, say:
AUTOMOBO_HWMON_MODULESAUTOMOBO_BUS_MODULESAnd modify the
lm_sensorsinitscript to recognize these too, or thinking more about this, as we need the script which does the copying of the config file to/etc/sensors.d/automobo.conf, to extract the modules for us anyways (to insert them into/etc/sysconfig/lm_sensorsfor example). We might just as well make that script load the modules directly.Quoted 4 lines
This also solves a problem with the HWMON_MODULES="it87" syntax, namely that it does not allow specifying module parameters.
Jean, could we have your input on this ?
No reply from Jean so far. So I'd like to make a proposal.
I'd suggest using the
install.shscript (which installs the automobo.conf) to load the driver. The config file gets a "modules" tag specifying the module name. E.g.#
board_name: foo
#board_vendor: bar
Quoted 8 lines
# modules: tmp421Sed gives us the module name and modprobe loads the module. I've extended the
install.shscript to do this. See the patch below (load_driverfunction).What do you think about this approach?
Sounds fine (and the proposed code looks good), but IMHO it would be better to have a module statement rather then a module*s*, which specifies
a single module, and then allow having this statement multiple times.
This way we can (optionally) add module parameters. Unfortunately in some rare cases this is necessary see, for example:
http://www.lm-sensors.org/wiki/Configurations/Abit/AN7
Regards,
Hans
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 1 line · Hans de Goede
Hi,
Hello Hans,
Quoted 7 lines
Sounds fine (and the proposed code looks good), but IMHO it would be better to have a module statement rather then a module*s*, which specifies
a single module, and then allow having this statement multiple times.This way we can (optionally) add module parameters. Unfortunately in some rare cases this is necessary see, for example:
http://www.lm-sensors.org/wiki/Configurations/Abit/AN7
I've revised the install.sh script a bit (see patch below). Now we can have the module statement multiple times along with parameters.
Regards,
Andre
---
Index: sensors/prog/detect/install.sh
=================================--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ sensors/prog/detect/install.sh 2010-04-13 20:59:26.931071291 +0200
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+SYSFS_PATH=/sys/class/dmi/id
+CONF_PATH=/var/lib/sensors/conf
+INSTALL_FILE=/etc/sensors.d/automobo.conf
+
+BOARD_VENDOR=cat $SYSFS_PATH/board_vendor
+BOARD_NAME=cat $SYSFS_PATH/board_name
+BOARD_VERSION=cat $SYSFS_PATH/board_version
+SYS_VENDOR=cat $SYSFS_PATH/sys_vendor
+PRODUCT_NAME=cat $SYSFS_PATH/product_name
+PRODUCT_VERSION=cat $SYSFS_PATH/product_version
+
+# only for testing
+#BOARD_VENDOR=Fujitsu
+#BOARD_NAMEÒ312C1
+#BOARD_VERSION=1.0
+#SYS_VENDOR=Fujitsu
+#PRODUCT_NAMEÒ312D2
+#PRODUCT_VERSION=2.0
+ +SEARCH_BOARD_VERSION=$CONF_PATH"/"$BOARD_VENDOR"_"$BOARD_NAME"_"$BOARD_VERSION +SEARCH_BOARD=$CONF_PATH"/"$BOARD_VENDOR"_"$BOARD_NAME +SEARCH_SYS_VERSION=$CONF_PATH"/"$SYS_VENDOR"_"$PRODUCT_NAME"_"$PRODUCT_VERSION +SEARCH_SYS=$CONF_PATH"/"$SYS_VENDOR"_"$PRODUCT_NAME
+
+load_drivers()
+{
+ while read a b c; do
+ if [ "$a" = "#" ]; then
+ if [ "$b" = "module:" ]; then
+ driver=echo $c | tr -d '\r'
+ echo "Loading driver: $driver"
+ modprobe $driver
+ fi
+ fi
+ done < $INSTALL_FILE
+}
+
+search_config()
+{
+ echo "Looking for config: $1"
+ if [ -h "$1" ]; then
+ echo "Found suitable config"
+ cp -f $1 $INSTALL_FILE
+ load_drivers
+ exit 0
+ fi
+}
+
+for search in "$SEARCH_BOARD_VERSION" "$SEARCH_BOARD" "$SEARCH_SYS_VERSION" "$SEARCH_SYS" +do
+ search_config "$search"
+done
+
+echo "Could not find a suitable config"
+rm -f $INSTALL_FILE
+
+exit 1
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Andre,
Quoted 9 lines · Andre Prendel
Quoted 1 line · Hans de Goede
Hi,
Hello Hans,
Quoted 4 lines
Sounds fine (and the proposed code looks good), but IMHO it would be better to have a module statement rather then a module*s*, which specifies
a single module, and then allow having this statement multiple times.
Quoted 7 lines
Quoted 3 lines
This way we can (optionally) add module parameters. Unfortunately in some rare cases this is necessary see, for example:
http://www.lm-sensors.org/wiki/Configurations/Abit/AN7I've revised the
install.shscript a bit (see patch below). Now we can have the module statement multiple times along with parameters.
Looks good!
Can you please repost the latest version of the entire set? Then I'll give it a more thorough review (and run some tests). And then if Jean also acks it we can commit it to svn :)
Regards,
Hans
Quoted 57 lines
Regards,
Andre---
Index:sensors/prog/detect/install.sh
=================================> ---/dev/null1970-01-01 00:00:00.000000000 +0000
+++sensors/prog/detect/install.sh2010-04-13 20:59:26.931071291 +0200(quoted diff) +49
-0@@ -0,0 +1,59 @@ +#!/bin/bash + +SYSFS_PATH=/sys/class/dmi/id +CONF_PATH=/var/lib/sensors/conf +INSTALL_FILE=/etc/sensors.d/automobo.conf + +BOARD_VENDOR=`cat $SYSFS_PATH/board_vendor` +BOARD_NAME=`cat $SYSFS_PATH/board_name` +BOARD_VERSION=`cat $SYSFS_PATH/board_version` +SYS_VENDOR=`cat $SYSFS_PATH/sys_vendor` +PRODUCT_NAME=`cat $SYSFS_PATH/product_name` +PRODUCT_VERSION=`cat $SYSFS_PATH/product_version` + +# only for testing +#BOARD_VENDOR=Fujitsu +#BOARD_NAMEÒ312C1 +#BOARD_VERSION=1.0 +#SYS_VENDOR=Fujitsu +#PRODUCT_NAMEÒ312D2 +#PRODUCT_VERSION=2.0 + +SEARCH_BOARD_VERSION=$CONF_PATH"/"$BOARD_VENDOR"_"$BOARD_NAME"_"$BOARD_VERSION +SEARCH_BOARD=$CONF_PATH"/"$BOARD_VENDOR"_"$BOARD_NAME +SEARCH_SYS_VERSION=$CONF_PATH"/"$SYS_VENDOR"_"$PRODUCT_NAME"_"$PRODUCT_VERSION +SEARCH_SYS=$CONF_PATH"/"$SYS_VENDOR"_"$PRODUCT_NAME + +load_drivers() +{ + while read a b c; do + if [ "$a" = "#" ]; then + if [ "$b" = "module:" ]; then + driver=`echo $c | tr -d '\r'` + echo "Loading driver: $driver" + modprobe $driver + fi + fi + done< $INSTALL_FILE +} + +search_config() +{ + echo "Looking for config: $1" + if [ -h "$1" ]; then + echo "Found suitable config" + cp -f $1 $INSTALL_FILE + load_drivers + exit 0 + fi +}
Review line 59
Quoted 10 lines
(quoted diff) +10
-0+ +for search in "$SEARCH_BOARD_VERSION" "$SEARCH_BOARD" "$SEARCH_SYS_VERSION" "$SEARCH_SYS" +do + search_config "$search" +done + +echo "Could not find a suitable config" +rm -f $INSTALL_FILE + +exit 1
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors