Bug#843446: thinkfan fails to starts with hwmon temperature sources

2017-01-04 Thread Francesco Montanari
Dear Maintainer,

The workaround I previously proposed does not really solves the
problem, because of course CPU temperature is not necessarily
related to that of hard disks.

I now reconfigure /etc/thinkfan.conf automatically each time. To do
that I added an ExecStartPre entry to thinkfan.service to load the
script here attached for completeness. It seems to work fine, but
please note that i) the script may be fine tuned to my machine, ii) I
am guessing that the thinkfan service will always start after that the
hwmon devices have been determined, ii) I have no expertise with init
scripts.

Best,
Francesco
#!/usr/bin/perl

# thinkfan-hwmon - automatic /etc/thinkfan.conf configuration
#
# Copyright (C) 2017 Francesco Montanari 
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .
#
#
# Description
# ---
# Automatically read hwmon sensors devices. Remove any previous
# 'hwmon /sys/devices/...'  entry from /etc/thinkfan.conf, and replace
# them by the newly detected ones.
#
# The script can be placed, e.g., under /usr/sbin/ and be called by
# thinkfan systemd service by adding the line
#   ExecStartPre=/usr/sbin/thinkfan-hwmon
# to the file /lib/systemd/system/thinkfan.service.
#
# Depending on the machine, the excluded folder name 'pci:00' may
# need to be adapted in this script.


use strict;
use warnings;
use File::Find::Rule;


# Where to look for the sensors
my $searchdir = "/sys/devices/";

# Exclude from the search those paths containing the following
# expression. This may change for different machines.
my $exclude = "pci:00";

my @cpu = read_sensors($searchdir,$exclude);

write_conf(@cpu);


sub read_sensors {
# Read the location of hwmon devices.

my @cpu = File::Find::Rule->file()
->name("temp*_input")
->in($searchdir);

my @del_indexes = grep { $cpu[$_] =~ m/\Q$exclude/ } 0..$#cpu;
for (@del_indexes){
splice(@cpu,$_,1);
}

for (@cpu)
{
$_ = "hwmon " . $_ . "\n";
}

return @cpu;
}


sub write_conf {
# Replace the sensors in the configuration file.

my $filename = '/etc/thinkfan.conf';

open my $in, '<', $filename or die "Could not open file '$filename' $!";
my @contents = <$in>;
close $in;

@contents = grep {!/hwmon \/sys\/device/} @contents;

open my $out, '>', $filename or die "Could not open file '$filename' $!";
print $out @contents;
print $out @cpu;
close $out;
}


Bug#843446: thinkfan fails to starts with hwmon temperature sources

2016-11-06 Thread Francesco Montanari
Package: thinkfan
Version: 0.9.2-1
Severity: important

Dear Maintainer,

Thinkfan sporadically fails to start as temperature sources unpredictably
change after reboot.

For example, the source:

/sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input

may change to:

/sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input

Hence, temperature sources need to be edited manually after each failure, and
the thinkfan service need to be restarted.

Compiling with SMART support (#747143), and using it instead of hwmon seems to
solve the problem for me.



-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (900, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.7.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages thinkfan depends on:
ii  libc6  2.24-5

thinkfan recommends no packages.

thinkfan suggests no packages.

-- Configuration Files:
/etc/thinkfan.conf changed:
hwmon /sys/devices/virtual/hwmon/hwmon0/temp1_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp3_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp2_input
(0, 0,  55)
(1, 48, 60)
(2, 50, 61)
(3, 52, 63)
(4, 56, 65)
(5, 59, 66)
(7, 63, 32767)


-- no debconf information