From: Tom Hughes Date: Tue, 27 Oct 2020 19:56:38 +0000 (+0000) Subject: Fix monitoring of devices behind adaptec RAID cards X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/49448b664ef6185d2b39c1e5c447bd9772f93506 Fix monitoring of devices behind adaptec RAID cards --- diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index 8a2a35e20..e8f903f64 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -380,6 +380,13 @@ disks = disks.map do |disk| elsif smart =~ %r{^.*,(\d+)/(\d+)$} munin = "#{device}-#{Regexp.last_match(1)}:#{Regexp.last_match(2)}" end + elsif disk[:device] + device = disk[:device].sub("/dev/", "") + smart = disk[:smart_device] + + if smart =~ /^.*,(\d+),(\d+),(\d+)$/ + munin = "#{device}-#{Regexp.last_match(1)}:#{Regexp.last_match(2)}:#{Regexp.last_match(3)}" + end end elsif disk[:device] =~ %r{^/dev/(nvme\d+)n\d+$} device = Regexp.last_match(1) diff --git a/cookbooks/hardware/templates/default/ohai.rb.erb b/cookbooks/hardware/templates/default/ohai.rb.erb index 82194acf2..d223fa0c3 100644 --- a/cookbooks/hardware/templates/default/ohai.rb.erb +++ b/cookbooks/hardware/templates/default/ohai.rb.erb @@ -766,10 +766,11 @@ Ohai.plugin(:Hardware) do array[:disks].map! do |location| disk = disks.find { |disk| disk[:location] == location } + controller_number = controller[:number] - 1 device_number = disk[:device_number] - device = Dir.glob("#{host}/device/target*:1:#{device_number}/*:1:#{device_number}:0/scsi_generic/*").first disk[:device] = "/dev/#{File.basename(device)}" + disk[:smart_device] = "aacraid,#{controller_number},0,#{device_number}" disk[:arrays] << array[:id] disk[:id]