Sha256: acf35e19c1f184cd51a2a4b6871d70268a9df4a468ed33fd8b3750d2ddb4eb97

Contents?: true

Size: 1.04 KB

Versions: 11

Compression:

Stored size: 1.04 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
    if File.exists?("/etc/onering/facter.list")
      IO.readlines("/etc/onering/facter.list").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
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
onering-report-plugins-0.0.17 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.16 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.15 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.14 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.13 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.12 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.11 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.10 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.9 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.8 lib/reporter/default/properties_facter.rb
onering-report-plugins-0.0.7 lib/reporter/default/properties_facter.rb