]> git.openstreetmap.org Git - chef.git/commitdiff
Configure smartd for LSI MegaRAID disks
authorTom Hughes <tom@compton.nu>
Fri, 13 Mar 2015 10:47:19 +0000 (10:47 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 13 Mar 2015 10:51:42 +0000 (10:51 +0000)
cookbooks/hardware/recipes/default.rb

index 05d5c0794b2f69da68711e7bd73cfe492e220b2a..eac54e7648043b006d0aa39b2009a43529cfd4d0 100644 (file)
@@ -267,6 +267,24 @@ if status_packages["cciss-vol-status"]
   end
 end
 
+if status_packages["megaclisas-status"]
+  controller = 0
+
+  Dir.glob("/sys/class/scsi_host/host*") do |host|
+    driver = File.new("#{host}/proc_name").read.chomp
+
+    next unless driver == "megaraid_sas"
+
+    device = host.sub("/sys/class/scsi_host/host", "bus/")
+
+    IO.popen(["megacli", "-PDList", "-a#{controller}", "-NoLog"]).each do |line|
+      disks << { :device => device, :driver => "megaraid",  :id => Regexp.last_match[1] } if line =~ /^Device Id: ([0-9]+)$/
+    end
+
+    controller += 1
+  end
+end
+
 if disks.count > 0
   package "smartmontools"