Sha256: 7ab8ecf1ef16e803993395463c7476d3a25fe13cfdccfab29beaf17bd26b56c9

Contents?: true

Size: 1.04 KB

Versions: 49

Compression:

Stored size: 1.04 KB

Contents

if Facter::Util::Resolution.which('smartctl')
  disks = []
  letters = (('a'..'z').to_a + ('a'..'z').to_a.collect{|i| ('a'..'z').to_a.collect{|j| i+j }}.flatten)

  letters.each do |i|
    if File.exists?("/dev/sd#{i}")
      smart = {}

      Facter::Util::Resolution.exec("smartctl -A /dev/sd#{i}").to_s.lines.each do |line|
        next unless line =~ /^\s*[0-9]+/
        id, name, flag, value, worst, threshold, type, updated, failed, raw = line.strip.chomp.split(/\s+/)

        smart[:attributes] ||= []
        smart[:attributes] << {
          :id        => id.to_i,
          :name      => name.downcase.gsub(/[\s\-]+/, '_'),
          :value     => value.to_i,
          :worst     => worst.to_i,
          :threshold => threshold.to_i,
          :type      => type.downcase,
          :raw       => raw
        }
      end

      smart[:name] = "/dev/sd#{i}"
      
      disks << smart
    end
  end

  disks = disks.reject{|i| (i[:attributes] || {}).empty? }
 
  unless disks.empty?
    Facter.add('smart') do
      setcode { disks }
    end
  end
end

Version data entries

49 entries across 49 versions & 2 rubygems

Version Path
onering-report-0.6.13 lib/facter/onering_disk_smart.rb
onering-report-0.6.12 lib/facter/onering_disk_smart.rb
onering-report-0.6.11 lib/facter/onering_disk_smart.rb
onering-report-0.6.10 lib/facter/onering_disk_smart.rb
onering-report-0.6.9 lib/facter/onering_disk_smart.rb
onering-report-0.6.8 lib/facter/onering_disk_smart.rb
onering-report-0.6.7 lib/facter/onering_disk_smart.rb
onering-report-0.6.6 lib/facter/onering_disk_smart.rb
onering-report-0.6.5 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.65 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.64 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.63 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.62 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.61 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.60 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.59 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.58 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.57 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.56 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.55 lib/facter/onering_disk_smart.rb