From 5a1fd7132a85987e2e40f8dc75de5160bc57f8b4 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Mon, 13 May 2013 15:49:08 -0700 Subject: [PATCH] change the megaraid_physical_drives fact to probe with lsscsi The existing smartctl based probe fails on rhel6.x with these package versions: smartmontools-5.42-2.el6.x86_64 kernel-2.6.32-279.9.1.el6.x86_64 It's unknown if the smartctl probe works with other el6.x tool + kernel combinations. It's hoped that the lsscsi based probe will be more robost (unless the output format of lsscsi changes). --- lib/facter/megaraid.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/facter/megaraid.rb b/lib/facter/megaraid.rb index c6c389a..86ce897 100644 --- a/lib/facter/megaraid.rb +++ b/lib/facter/megaraid.rb @@ -10,6 +10,10 @@ def megacli_usable? Facter::Util::Resolution.which('MegaCli') end +def lsscsi_usable? + Facter::Util::Resolution.which('lsscsi') +end + Facter.add(:megaraid_physical_drives) do confine :kernel => [ :Linux ] setcode do @@ -49,11 +53,11 @@ def megacli_usable? confine :kernel => [ :Linux ] setcode do device = nil - if smartctl = Facter::Util::Resolution.which('smartctl') - out = Facter::Util::Resolution.exec(smartctl + ' --scan-open 2>&1') + if megacli_usable? + out = Facter::Util::Resolution.exec('lsscsi | awk \'{ if($2 == "disk" && $3 == "LSI") { print $6 } }\'') out.each_line do |line| - if line =~ /open failed: DELL or MegaRaid controller/ - device = (line.split(/\s+/))[0] + if line =~ /\/dev\/\S+/ + device = line end end end