]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/templates/default/ohai.rb.erb
Improve parsing of MD array status
[chef.git] / cookbooks / hardware / templates / default / ohai.rb.erb
index f6b854c99356054c76bb952ca8befc0d615b9325..97a8823c2c97d26e3e58dbb3e98a827db78bc7c2 100644 (file)
@@ -253,19 +253,10 @@ Ohai.plugin(:Hardware) do
   end
 
   def find_md_arrays(devices)
-    controller = {
-      :id => devices[:controllers].count,
-      :type => "md",
-      :arrays => [],
-      :disks => []
-    }
-
-    devices[:controllers] << controller
-
     array = nil
 
     File.new("/proc/mdstat", "r").each do |line|
-      if line =~ /^(md\d+) : active raid(\d+)((?: (?:sd[a-z]|nvme\d+n\d+)\d*\[\d+\](?:\([A-Z]\))*)+)$/
+      if line =~ /^(md\d+) : active raid(\d+)((?: (?:sd[a-z]\d*|nvme\d+n\d+(?:p\d+)?)\[\d+\](?:\([A-Z]\))*)+)$/
         array = {
           :id => devices[:arrays].count,
           :device => "/dev/#{Regexp.last_match(1)}",
@@ -294,7 +285,6 @@ Ohai.plugin(:Hardware) do
         end
 
         devices[:arrays] << array
-        controller[:arrays] << array[:id]
       elsif array && line =~ /^\s+(\d+) blocks.*(?:\[([U_]+)\])?/
         array[:size] = format_disk_size(Regexp.last_match(1).to_i)
         array[:status] = "degraded" if Regexp.last_match(2) =~ /_/