Sha256: f1d026e4a4f1e9173c95e34655973ab550ea0fa4b8baa30237102438abff1c1e
Contents?: true
Size: 1.18 KB
Versions: 37
Compression:
Stored size: 1.18 KB
Contents
# Onering Collector - Facter Properties plugin # provides a configurable list of Facter facts that should be sent to the # Onering API # # Properties defined in /etc/onering/facter.list # report do def cleanup_dirty_values(k, v) return case k when 'mbserial' then v.to_s.gsub(/(^\.+|\.+$)/,'').gsub('.','-') else (v.strip.chomp rescue v) end end if defined?(Facter) # get a list of Facter attributes to list local_list = File.join(File.dirname(File.dirname(File.dirname(__FILE__))),'etc','facter.list') facts = [ local_list, "/etc/onering/facter.list" ].collect{|file| IO.readlines(file) if File.exists?(file) }.flatten.compact.sort.uniq facts.each do |line| # strip whitespace/kill newline line.strip! line.chomp! next if line.empty? line = line.downcase unless line =~ /^#/ begin line = line.split(':') key = (line.length == 1 ? line.first : line.last) val = cleanup_dirty_values(key, Facter.value(line.first)) property key.to_sym, val rescue Exception STDERR.puts e.message next end end end end end
Version data entries
37 entries across 37 versions & 1 rubygems