-disks.each do |disk|
- if disk[:device] =~ /^cciss\/(.*)$/
- id = File.read("/sys/bus/cciss/devices/#{Regexp.last_match[1]}/unique_id").chomp
-
- disk[:munin] = "cciss-3#{id.downcase}"
- else
- disk[:munin] = disk[:device]
+disks = disks.map do |disk|
+ next if disk[:state] == "spun_down"
+
+ if disk[:smart_device]
+ controller = node[:hardware][:disk][:controllers][disk[:controller]]
+ device = controller[:device].sub("/dev/", "")
+ smart = disk[:smart_device]
+
+ if device.start_with?("cciss/") && smart =~ /^cciss,(\d+)$/
+ array = node[:hardware][:disk][:arrays][disk[:arrays].first]
+ munin = "cciss-3#{array[:wwn]}-#{Regexp.last_match(1)}"
+ elsif smart =~ /^.*,(\d+)$/
+ munin = "#{device}-#{Regexp.last_match(1)}"
+ elsif smart =~ %r{^.*,(\d+)/(\d+)$}
+ munin = "#{device}-#{Regexp.last_match(1)}:#{Regexp.last_match(2)}"
+ end
+ elsif disk[:device]
+ device = disk[:device].sub("/dev/", "")
+ munin = device