]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/recipes/default.rb
The smartd on 12.04 doesn't support /dev/bus syntax
[chef.git] / cookbooks / hardware / recipes / default.rb
index 05d5c0794b2f69da68711e7bd73cfe492e220b2a..c9da86168f4fe00eebcc0aabaa02dd967c1d33cc 100644 (file)
@@ -267,6 +267,39 @@ 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"
+
+    bus = host.sub("/sys/class/scsi_host/host", "")
+    device = File.basename(Dir.glob("/sys/bus/scsi/devices/#{bus}:*/scsi_generic/*").first)
+
+    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 status_packages["sas2ircu-status"]
+  Dir.glob("/sys/class/scsi_host/host*") do |host|
+    driver = File.new("#{host}/proc_name").read.chomp
+
+    next unless driver == "mpt2sas"
+
+    bus = host.sub("/sys/class/scsi_host/host", "")
+
+    Dir.glob("/sys/bus/scsi/devices/#{bus}:0:*/scsi_generic/*").each do |sg|
+      disks << { :device => File.basename(sg) }
+    end
+  end
+end
+
 if disks.count > 0
   package "smartmontools"