]> git.openstreetmap.org Git - chef.git/commitdiff
Initial work to manage lm_sensors
authorTom Hughes <tom@compton.nu>
Wed, 23 Jul 2014 19:55:57 +0000 (20:55 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 23 Jul 2014 20:04:08 +0000 (21:04 +0100)
cookbooks/hardware/attributes/default.rb
cookbooks/hardware/libraries/sensors.rb [new file with mode: 0644]
cookbooks/hardware/recipes/default.rb
cookbooks/hardware/templates/default/sensors.conf.erb [new file with mode: 0644]
cookbooks/munin/recipes/default.rb
cookbooks/munin/templates/default/disable-bad-acpi-sensor.conf.erb [deleted file]
roles/errol.rb
roles/orm.rb
roles/poldi.rb
roles/tyan-s7010.rb [new file with mode: 0644]
roles/yevaud.rb

index 39b272b05d4f9c4da6322931ddbe90e477e41616..473ceb1811249ac6922131b19aeab390ddd18ca0 100644 (file)
@@ -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" ]
 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
 
   end
 end
 
diff --git a/cookbooks/hardware/libraries/sensors.rb b/cookbooks/hardware/libraries/sensors.rb
new file mode 100644 (file)
index 0000000..512ba31
--- /dev/null
@@ -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
index 7923d3868d0213e8114ba0225c3628c78f9a2fac..f6eb31ee396d3e7a2c8e0309fe01c4ff43afa625 100644 (file)
@@ -269,3 +269,22 @@ if watchdog
     action [ :enable, :start ]
   end
 end
     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 (file)
index 0000000..fb1bdb2
--- /dev/null
@@ -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 -%>
index ae5eb6caee1e537f97a26f58318d4c4d285eec38..c2a360aa4011ca1e56db444738568b7d20304d6d 100644 (file)
@@ -79,18 +79,6 @@ remote_directory "/etc/munin/plugin-conf.d" do
   notifies :restart, "service[munin-node]"
 end
 
   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
 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 (file)
index 58c1062..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-chip "power_meter-*"
-  ignore power1
index 61bf2e15b4c7a969e70e2c600646630d03185de6..a74cf845272372c75ee583fee0eaaaa33ab439d7 100644 (file)
@@ -2,37 +2,6 @@ name "errol"
 description "Master role applied to errol"
 
 default_attributes(
 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",
   :devices => {
     :osdsk => {
       :comment => "First os disk",
@@ -75,5 +44,6 @@ default_attributes(
 
 run_list(
   "role[ucl-wolfson]",
 
 run_list(
   "role[ucl-wolfson]",
+  "role[tyan-s7010]",
   "role[dev]"
 )
   "role[dev]"
 )
index 51ff04b40af367a7da8d6aac98e2daaddb5852c5..9d1653a16ad471705494477a89cb57ace85d71fc 100644 (file)
@@ -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 => {
   :networking => {
     :interfaces => {
       :external_ipv4 => {
@@ -118,5 +82,6 @@ override_attributes(
 
 run_list(
   "role[ic]",
 
 run_list(
   "role[ic]",
+  "role[tyan-s7010]",
   "role[tile]"
 )
   "role[tile]"
 )
index 46ba3963eaade5865a09a6fab3d50a4f24f2fc23..855e645aa7b90e07c0879a7f4057c9750c1eb814 100644 (file)
@@ -81,36 +81,11 @@ default_attributes(
             :max_children => "10"
         }
     }
             :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]",
   }
 )
 
 run_list(
   "role[ucl-wolfson]",
+  "role[tyan-s7010]",
   "role[nominatim]"
 )
   "role[nominatim]"
 )
diff --git a/roles/tyan-s7010.rb b/roles/tyan-s7010.rb
new file mode 100644 (file)
index 0000000..87e77e7
--- /dev/null
@@ -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:" }
+      }
+    }
+  }
+)
index 299005da214c0e81cd1082ffa34d1bd2dc82f6c2..7dcace09d32510d3e71b7ca9f6b997866949af12 100644 (file)
@@ -58,29 +58,6 @@ default_attributes(
           :warning => 150,
           :critical => 200
         }
           :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]",
 
 run_list(
   "role[ucl-wolfson]",
+  "role[tyan-s7010]",
   "role[tile]"
 )
   "role[tile]"
 )