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