Sha256: 788058318dcc01b1fac4414b71303ec8bb3373fd974d8f8019a42a3cb89384e9

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 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 => e
          Onering::Logger.debug(e.message, "onering-report-plugins/properties_facter/#{e.class.name}")
          next
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
onering-report-plugins-0.0.61 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.60 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.59 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.58 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.57 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.56 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.55 lib/reporter/default/properties_facter.rb