]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
collectd: run sensors-detect in background
authorArne Fitzenreiter <arne_f@ipfire.org>
Wed, 25 Mar 2020 06:35:38 +0000 (07:35 +0100)
committerArne Fitzenreiter <arne_f@ipfire.org>
Thu, 26 Mar 2020 09:43:10 +0000 (09:43 +0000)
on some machines the i2c sensor search take very long time
which cause hang at first boot.

Now the search is started in background and waited for max one
minute before continue load of collectd.
On such machines collectd will not get all sensors at first startup.

fixes #12329

Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
src/initscripts/system/collectd

index 5233525f0460006a6a5765d8fad554dc20ed34db..20072780a723fcd344992ba885328bc8227c705a 100644 (file)
@@ -6,6 +6,28 @@
 
 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
 
+scan_for_sensors() {
+       touch /var/lock/sensors_search
+       # pre scan and try to load modules
+       "yes" | /usr/sbin/sensors-detect > /dev/null
+       if [ -e /etc/sysconfig/lm_sensors ]; then
+
+               # Module load
+               . /etc/sysconfig/lm_sensors
+               for modul in $BUS_MODULES $HWMON_MODULES ; do
+                       modprobe $modul > /dev/null 2>&1;
+               done
+       fi
+
+       # Final scan
+       "yes" | /usr/sbin/sensors-detect > /dev/null
+
+       if [ ! -e /etc/sysconfig/lm_sensors ]; then
+               echo "#No Sensors detected " > /etc/sysconfig/lm_sensors
+       fi
+       rm /var/lock/sensors_search
+}
+
 if [ "$RRDLOG" = '' ]; then
        RRDLOG=/var/log/rrd
 fi
@@ -42,27 +64,23 @@ case "$1" in
 
                # At first run search for sensors with sensors-detect
                if [ ! -e /etc/sysconfig/lm_sensors ]; then
-                       boot_mesg "Searching for Sensors..."
-
-                       # pre scan and try to load modules
-                       "yes" | /usr/sbin/sensors-detect > /dev/null
-                       if [ -e /etc/sysconfig/lm_sensors ]; then
-
-                               # Module load
-                               . /etc/sysconfig/lm_sensors
-                               for modul in $BUS_MODULES $HWMON_MODULES ; do
-                                       modprobe $modul > /dev/null 2>&1;
-                               done
-                       fi
-
-                       # Final scan
-                       "yes" | /usr/sbin/sensors-detect > /dev/null
-                       evaluate_retval
+                       # Don't run at next boot again
+                       touch /etc/sysconfig/lm_sensors
+                       boot_mesg -n "Searching for Sensors..."
+                       scan_for_sensors &
+                       sleep 2
+               fi
 
-                       if [ ! -e /etc/sysconfig/lm_sensors ]; then
-                               echo "#No Sensors detected " > /etc/sysconfig/lm_sensors
-                       fi
+               if [ -e /var/lock/sensors_search ]; then
+                       for (( i=1; i<30; i++)) do
+                               if [ ! -e /var/lock/sensors_search ]; then
+                                       break;
+                               fi
+                               boot_mesg -n "."
+                               sleep 2
+                       done
                fi
+               boot_mesg ""
 
                # Load sensor modules only first start
                if [ ! -e /var/lock/sensors_modules ]; then