]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/recipes/default.rb
Don't do SMART checks on spun down disks
[chef.git] / cookbooks / hardware / recipes / default.rb
index c2918524826731b404840f47e351e5727cab8f85..d929bbf5746f3ae6927bcd05529bb7ded68175b4 100644 (file)
@@ -298,6 +298,8 @@ end
 end
 
 disks = node[:hardware][:disk][:disks].map do |disk|
+  next if disk[:state] == "spun_down"
+
   if disk[:smart_device]
     controller = node[:hardware][:disk][:controllers][disk[:controller]]
     device = controller[:device].sub("/dev/", "")
@@ -311,11 +313,13 @@ disks = node[:hardware][:disk][:disks].map do |disk|
     elsif smart =~ %r{^.*,(\d+)/(\d+)$}
       munin = "#{device}-#{Regexp.last_match(1)}:#{Regexp.last_match(2)}"
     end
-  else
+  elsif disk[:device]
     device = disk[:device].sub("/dev/", "")
     munin = device
   end
 
+  next if device.nil?
+
   Hash[
     :device => device,
     :smart => smart,
@@ -324,6 +328,8 @@ disks = node[:hardware][:disk][:disks].map do |disk|
   ]
 end
 
+disks = disks.compact
+
 if disks.count > 0
   package "smartmontools"