From: Tom Hughes Date: Wed, 23 Jul 2014 19:55:57 +0000 (+0100) Subject: Initial work to manage lm_sensors X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/8ad66df69a108a031ff4fb869f002a6598005649?ds=sidebyside Initial work to manage lm_sensors --- diff --git a/cookbooks/hardware/attributes/default.rb b/cookbooks/hardware/attributes/default.rb index 39b272b05..473ceb181 100644 --- a/cookbooks/hardware/attributes/default.rb +++ b/cookbooks/hardware/attributes/default.rb @@ -1,7 +1,14 @@ +default[:hardware][:sensors] = {} + if node[:dmi] and node[:dmi][:system] case dmi.system.manufacturer when "HP" default[:apt][:sources] |= [ "management-component-pack" ] + + case dmi.system.product_name + when "ProLiant DL360 G6", "ProLiant DL360 G7" + default[:hardware][:sensors][:power][:power1] = { :ignore => true } + end end end diff --git a/cookbooks/hardware/libraries/sensors.rb b/cookbooks/hardware/libraries/sensors.rb new file mode 100644 index 000000000..512ba31ff --- /dev/null +++ b/cookbooks/hardware/libraries/sensors.rb @@ -0,0 +1,30 @@ +class Chef + class Sensors + def self.attributes(sensors, attribute_names) + sensors ||= {} + results = [] + + sensors.sort.each do |sensor,attributes| + if attributes[:ignore] + results << "ignore #{sensor}" + else + if label = attributes[:label] + resuls << "label #{sensor} \"#{label}\"" + end + + if compute = attributes[:compute] + resuls << "compute #{sensor} #{compute}" + end + + attribute_names.each do |name| + if value = attributes[name] + results << "set #{sensor}_#{name} #{value}" + end + end + end + end + + results.map { |r| " #{r}\n" }.join("") + end + end +end diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index 7923d3868..f6eb31ee3 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -269,3 +269,22 @@ if watchdog action [ :enable, :start ] end end + +unless Dir.glob("/sys/class/hwmon/hwmon*").empty? + package "lm-sensors" + + execute "/etc/sensors.d/chef.conf" do + action :nothing + command "/usr/bin/sensors -s" + user "root" + group "root" + end + + template "/etc/sensors.d/chef.conf" do + source "sensors.conf.erb" + owner "root" + group "root" + mode 0644 + notifies :run, "execute[/etc/sensors.d/chef.conf]" + end +end diff --git a/cookbooks/hardware/templates/default/sensors.conf.erb b/cookbooks/hardware/templates/default/sensors.conf.erb new file mode 100644 index 000000000..fb1bdb2e2 --- /dev/null +++ b/cookbooks/hardware/templates/default/sensors.conf.erb @@ -0,0 +1,9 @@ +# DO NOT EDIT - This file is being maintained by Chef +<% node[:hardware][:sensors].sort.each do |chip,sensors| -%> + +chip "<%= chip %>" +<%= Chef::Sensors.attributes sensors[:volts], [:min, :max] -%> +<%= Chef::Sensors.attributes sensors[:fans], [:min] -%> +<%= Chef::Sensors.attributes sensors[:temps], [:max, :max_hyst, :crit, :crit_hyst] -%> +<%= Chef::Sensors.attributes sensors[:power], [:interval] -%> +<% end -%> diff --git a/cookbooks/munin/recipes/default.rb b/cookbooks/munin/recipes/default.rb index ae5eb6cae..c2a360aa4 100644 --- a/cookbooks/munin/recipes/default.rb +++ b/cookbooks/munin/recipes/default.rb @@ -79,18 +79,6 @@ remote_directory "/etc/munin/plugin-conf.d" do notifies :restart, "service[munin-node]" end -if node[:dmi] and node[:dmi][:system] and node[:dmi][:system][:manufacturer] == "HP" - case node[:dmi][:system][:product_name] - when "ProLiant DL360 G6", "ProLiant DL360 G7" - template "/etc/sensors.d/disable-bad-acpi-sensor.conf" do - source "disable-bad-acpi-sensor.conf.erb" - owner "root" - group "root" - mode 0644 - end - end -end - if Dir.glob("/proc/acpi/thermal_zone/*/temperature").empty? munin_plugin "acpi" do action :delete diff --git a/cookbooks/munin/templates/default/disable-bad-acpi-sensor.conf.erb b/cookbooks/munin/templates/default/disable-bad-acpi-sensor.conf.erb deleted file mode 100644 index 58c1062ec..000000000 --- a/cookbooks/munin/templates/default/disable-bad-acpi-sensor.conf.erb +++ /dev/null @@ -1,3 +0,0 @@ -# DO NOT EDIT - This file is being maintained by Chef -chip "power_meter-*" - ignore power1 diff --git a/roles/errol.rb b/roles/errol.rb index 61bf2e15b..a74cf8452 100644 --- a/roles/errol.rb +++ b/roles/errol.rb @@ -2,37 +2,6 @@ name "errol" description "Master role applied to errol" default_attributes( - :munin => { - :plugins => { - :ipmi_fans => { - :Sys3Front1 => { :graph => "no" }, - :Sys4Front2 => { :graph => "no" }, - :Sys5Rear1 => { :graph => "no" }, - :Sys6 => { :graph => "no" }, - :Sys7 => { :graph => "no" }, - :Sys8 => { :graph => "no" }, - :Sys9 => { :graph => "no" }, - :Sys10 => { :graph => "no" } - }, - :ipmi_temp => { - :CPU0belowTmax => { :critical => "10:" }, - :CPU1belowTmax => { :critical => "10:" } - }, - :sensors_fan => { - :contacts => "null" - }, - :sensors_temp => { - :contacts => "null" - }, - :sensors_volt => { - :contacts => "null", - :volt10 => { - :warning => "3.11:3.50", - :critical => "2.98:3.63" - } - } - } - }, :devices => { :osdsk => { :comment => "First os disk", @@ -75,5 +44,6 @@ default_attributes( run_list( "role[ucl-wolfson]", + "role[tyan-s7010]", "role[dev]" ) diff --git a/roles/orm.rb b/roles/orm.rb index 51ff04b40..9d1653a16 100644 --- a/roles/orm.rb +++ b/roles/orm.rb @@ -26,42 +26,6 @@ default_attributes( } } }, - :munin => { - :plugins => { - :ipmi_fans => { - :Sys3Front1 => { :graph => "no" }, - :Sys4Front2 => { :graph => "no" }, - :Sys5Rear1 => { :graph => "no" }, - :Sys6 => { :graph => "no" }, - :Sys7 => { :graph => "no" }, - :Sys8 => { :graph => "no" }, - :Sys9 => { :graph => "no" }, - :Sys10 => { :graph => "no" } - }, - :ipmi_temp => { - :CPU0belowTmax => { :critical => "10:" }, - :CPU1belowTmax => { :critical => "10:" } - }, - :sensors_fan => { - :fan3 => { :graph => "no" }, - :fan4 => { :graph => "no" }, - :fan5 => { :graph => "no" }, - :fan6 => { :graph => "no" }, - :fan7 => { :graph => "no" }, - :fan8 => { :graph => "no" }, - :fan9 => { :graph => "no" }, - :fan10 => { :graph => "no" }, - :fan11 => { :graph => "no" }, - :fan12 => { :graph => "no" } - }, - :sensors_volt => { - :contacts => "null", - :volt6 => { - :warning => "2.992:3.536" - } - } - } - }, :networking => { :interfaces => { :external_ipv4 => { @@ -118,5 +82,6 @@ override_attributes( run_list( "role[ic]", + "role[tyan-s7010]", "role[tile]" ) diff --git a/roles/poldi.rb b/roles/poldi.rb index 46ba3963e..855e645aa 100644 --- a/roles/poldi.rb +++ b/roles/poldi.rb @@ -81,36 +81,11 @@ default_attributes( :max_children => "10" } } - }, - :munin => { - :plugins => { - :ipmi_fans => { - :Sys3Front1 => { :graph => "no" }, - :Sys4Front2 => { :graph => "no" }, - :Sys5Rear1 => { :graph => "no" }, - :Sys6 => { :graph => "no" }, - :Sys7 => { :graph => "no" }, - :Sys8 => { :graph => "no" }, - :Sys9 => { :graph => "no" }, - :Sys10 => { :graph => "no" } - }, - :ipmi_temp => { - :CPU0belowTmax => { :critical => "10:" }, - :CPU1belowTmax => { :critical => "10:" } - }, - :sensors_volt => { - :volt6 => { - :warning => "2.992:3.536" - }, - :volt10 => { - :warning => "2.71:3.29" - } - } - } } ) run_list( "role[ucl-wolfson]", + "role[tyan-s7010]", "role[nominatim]" ) diff --git a/roles/tyan-s7010.rb b/roles/tyan-s7010.rb new file mode 100644 index 000000000..87e77e7fc --- /dev/null +++ b/roles/tyan-s7010.rb @@ -0,0 +1,56 @@ +name "tyan-s7010" +description "Role applied to machines using the Tyan S710 motherboard" + +default_attributes( + :hardware => { + :sensors => { + "jc42-*" => { + :temps => { + "temp1" => { :max => 75 } + } + }, + "w83793-i2c-*-2f" => { + :volts => { + "in0" => { :min => 0.696, :max => 1.424 }, + "in1" => { :min => 0.696, :max => 1.424 }, + "in5" => { :min => 2.992, :max => 3.536 }, + "in9" => { :min => 2.608, :max => 3.536 } + }, + :fans => { + "fan3" => { :ignore => true }, + "fan4" => { :ignore => true }, + "fan5" => { :ignore => true }, + "fan6" => { :ignore => true }, + "fan7" => { :ignore => true }, + "fan8" => { :ignore => true }, + "fan9" => { :ignore => true }, + "fan10" => { :ignore => true }, + "fan11" => { :ignore => true }, + "fan12" => { :ignore => true } + }, + :temps => { + "temp5" => { :max => 78, :max_hyst => 73 }, + "temp6" => { :max => 78, :max_hyst => 73 } + } + } + }, + }, + :munin => { + :plugins => { + :ipmi_fans => { + :Sys3Front1 => { :graph => "no" }, + :Sys4Front2 => { :graph => "no" }, + :Sys5Rear1 => { :graph => "no" }, + :Sys6 => { :graph => "no" }, + :Sys7 => { :graph => "no" }, + :Sys8 => { :graph => "no" }, + :Sys9 => { :graph => "no" }, + :Sys10 => { :graph => "no" } + }, + :ipmi_temp => { + :CPU0belowTmax => { :critical => "10:" }, + :CPU1belowTmax => { :critical => "10:" } + } + } + } +) diff --git a/roles/yevaud.rb b/roles/yevaud.rb index 299005da2..7dcace09d 100644 --- a/roles/yevaud.rb +++ b/roles/yevaud.rb @@ -58,29 +58,6 @@ default_attributes( :warning => 150, :critical => 200 } - }, - :ipmi_fans => { - :Sys3Front1 => { :graph => "no" }, - :Sys4Front2 => { :graph => "no" }, - :Sys5Rear1 => { :graph => "no" }, - :Sys6 => { :graph => "no" }, - :Sys7 => { :graph => "no" }, - :Sys8 => { :graph => "no" }, - :Sys9 => { :graph => "no" }, - :Sys10 => { :graph => "no" } - }, - :ipmi_temp => { - :CPU0belowTmax => { :critical => "10:" }, - :CPU1belowTmax => { :critical => "10:" } - }, - :sensors_fan => { - :contacts => "null" - }, - :sensors_temp => { - :contacts => "null" - }, - :sensors_volt => { - :contacts => "null" } } }, @@ -134,5 +111,6 @@ default_attributes( run_list( "role[ucl-wolfson]", + "role[tyan-s7010]", "role[tile]" )