Sha256: b1e5767f8d16a8f34a963766de27d6f311161c48f3ce09186fd644c7dee7b313

Contents?: true

Size: 1.57 KB

Versions: 64

Compression:

Stored size: 1.57 KB

Contents

# Onering Collector - Ohai Properties plugin
#   provides a configurable list of Ohai attributes that should be sent to the
#   Onering API
#
#   Properties defined in /etc/onering/ohai.list
#

report do
  if defined?(Ohai)
    def cleanup_dirty_values(k, v)
      return case k
      when 'mbserial' then v.to_s.gsub(/(^\.+|\.+$)/,'').gsub('.','-')
      else v
      end
    end

    # get a list of ohai attributes to list
    if File.exists?("/etc/onering/ohai.list")
      IO.readlines("/etc/onering/ohai.list").each do |line|
      # trip whitespace/kill newline
        line.strip!
        line.chomp!
        next if line.empty?
        line = line.downcase

        unless line =~ /^#/
          begin
            parts = line.split(".")
            root = @ohai

            parts.each do |part|
              part = part.split(':')
              key = part.first
              alt = part.last

              if root[key]
                if root[key].is_a?(Hash)
                  root = root[key]
                  next
                else
                  val = [*root[key]].collect{|i| i.strip.chomp rescue i }
                  val = val.first if val.length == 1
                  val = cleanup_dirty_values(alt, val)
                  val.strip! if val.is_a?(String)

                # set property value
                  property alt, val
                  break
                end
              else
                break
              end
            end
          rescue Exception
            STDERR.puts e.message
            next
          end
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
onering-report-plugins-0.0.64 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.63 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.62 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.61 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.60 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.59 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.58 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.57 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.56 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.55 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.54 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.53 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.52 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.51 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.50 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.49 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.48 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.47 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.46 lib/reporter/default/properties_ohai.rb
onering-report-plugins-0.0.45 lib/reporter/default/properties_ohai.rb