Sha256: 7201cf4b650df10b5087b700282d7bb7ad5371d46eff3df72b3824e455690175
Contents?: true
Size: 1.33 KB
Versions: 12
Compression:
Stored size: 1.33 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.uniq facts.each do |line| Onering::Logger.debug3("-> Facter Line: #{line.inspect}", "Onering::Reporter") # 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 => e Onering::Logger.debug(e.message, "onering-report-plugins/properties_facter/#{e.class.name}") next end end end end end
Version data entries
12 entries across 12 versions & 2 rubygems