Skip to content

Instantly share code, notes, and snippets.

@devicenull
Created May 18, 2012 00:48
Show Gist options
  • Save devicenull/2722503 to your computer and use it in GitHub Desktop.
Save devicenull/2722503 to your computer and use it in GitHub Desktop.
raidcontroller.rb
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