From: Tom Hughes Date: Mon, 5 Oct 2015 08:26:51 +0000 (+0100) Subject: Autoconfigure sensible labels for Intel coretemp sensors X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/dec057e6577390c14f4ec63572ec81d72ac30430 Autoconfigure sensible labels for Intel coretemp sensors --- diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index 2938b763c..9e1af16ef 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -536,6 +536,24 @@ end unless Dir.glob("/sys/class/hwmon/hwmon*").empty? package "lm-sensors" + Dir.glob("/sys/devices/platform/coretemp.*").each do |coretemp| + cpu = File.basename(coretemp).sub("coretemp.", "").to_i + chip = format("coretemp-isa-%04d", cpu) + + temps = Dir.glob("#{coretemp}/temp*_input").map do |temp| + File.basename(temp).sub("temp", "").sub("_input", "").to_i + end.sort + + if temps.first == 1 + node.default[:hardware][:sensors][chip][:temps][:temp1][:label] = "CPU #{cpu}" + temps.shift + end + + temps.each_with_index do |temp, index| + node.default[:hardware][:sensors][chip][:temps]["temp#{temp}"][:label] = "CPU #{cpu} Core #{index}" + end + end + execute "/etc/sensors.d/chef.conf" do action :nothing command "/usr/bin/sensors -s"