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

Version Path
onering-report-plugins-0.0.54 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.53 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.52 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.51 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.50 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.49 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.48 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.47 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.46 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.45 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.44 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.43 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.42 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.41 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.40 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.39 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.38 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.37 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.36 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.35 lib/reporter/default/properties_facter.rb