Permalink
Browse files

updating, to current version.

  • Loading branch information...
gpapilion committed Dec 25, 2011
1 parent d9de7a7 commit f75e6d3cd489dc8b9287733493568f8770c993a5
Showing with 31 additions and 7 deletions.
  1. +25 −5 ohai/plugins/raid_controllers.rb
  2. +6 −2 ohai/plugins/raid_controllers_lsi.rb
@@ -1,11 +1,31 @@
-provides "raid_controllers"
-raid_controllers Mash.new()
-ls_pci_output = %x[lspci|grep RAID]
+provides "raid/controllers"
+
+if File.exists?("/usr/bin/lspci")
+ ls_pci_output = %x[/usr/bin/lspci -m | /bin/grep -i raid]
+else
+ return 0
+end
+
+if ls_pci_output.size < 1
+ return 0
+end
+
+raid_controllers Mash.new()
+
i = 0
ls_pci_output.each_line do
|line|
- controller = line.split(": ")
+ controller = line.split
raid_controllers[i.to_s] = Mash.new()
- raid_controllers[i.to_s][:type] = controller[1].chomp
+ rs = String.new()
+ controller.slice(4..-1).each {
+ |e|
+ if rs == ''
+ rs = e.sub(/"/, '').chomp()
+ else
+ rs = rs + " " + e.sub(/"/,'').chomp()
+ end
+ }
+ raid_controllers[i.to_s][:type] = rs
i = i+1
end
@@ -2,12 +2,15 @@
LSI_RAID_UTIL = "/usr/local/bin/MegaCli64"
+if not File.exists?(LSI_RAID_UTIL)
+ return 0
+end
+
lsi_num = 0
raid_controllers.keys.each do
|controller_number|
if raid_controllers[controller_number][:type] =~ /^LSI/
- raid_controllers[controller_number][:volumes] = Mash.new
raid_vl_output = %x[#{LSI_RAID_UTIL} -LdPdInfo -a#{lsi_num}]
raid_controller = Hash.new()
@@ -20,8 +23,9 @@
raid_vl_output.each_line do
|line|
- if line =~ /^Number of Virtual Disks:/
+ if line =~ /^Number of Virtual Disks: [1-9]/
number_of_vdisks = line.split(": ")[1].to_i
+ raid_controllers[controller_number][:volumes] = Mash.new
end
if line =~ /^\n$/

0 comments on commit f75e6d3

Please sign in to comment.