Created
May 18, 2012 00:48
raidcontroller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Facter.add("raidcontroller") do | |
confine :kernel => :linux | |
ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin" | |
setcode do | |
controllers = [] | |
lspciexists = system "/bin/bash -c 'which lspci >&/dev//null'" | |
if $?.exitstatus == 0 | |
output = %x{lspci} | |
output.each {|s| | |
controllers.push("megaraid") if s =~ /RAID bus controller: .* MegaRAID .*/ | |
controllers.push("3ware") if s =~ /RAID bus controller: 3ware .*/ | |
} | |
end | |
if FileTest.exists?("/proc/mdstat") | |
txt = File.read("/proc/mdstat") | |
controllers.push("software") if txt =~ /^md/i | |
end | |
controllers.join(",") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment