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-plugins-0.0.54 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.53 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.52 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.51 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.50 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.49 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.48 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.47 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.46 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.45 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.44 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.43 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.42 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.41 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.40 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.39 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.38 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.37 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.36 lib/facter/onering_disk_smart.rb
onering-report-plugins-0.0.35 lib/facter/onering_disk_smart.rb